以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]计划管理长时间运行导致内存过高系统死机  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=91931)

--  作者:智友软件工作室
--  发布时间:2016/10/22 10:24:00
--  [求助]计划管理长时间运行导致内存过高系统死机
计划管理,每三分钟运行一次,一般运行3小时之后,内存过高,系统死机,请帮忙看看问题出现在哪里。
以下是计划管理中的代码。

Dim url As String = "http://task.zbj.com/t-rjkf/?t=5"
Dim web As new System.Windows.Forms.WebBrowser
web.ScriptErrorsSuppressed = True
web.Navigate(url)
Do While web.ReadyState <> 4
    Application.DoEvents
Loop
Dim biaoti As String
Dim neirong As String
Dim trs = web.Document.GetElementsByTagName("table")(0).GetElementsByTagName("tr")
For j As Integer = 1 To trs.count - 1
    Dim tr = trs(j)
    Dim tds = tr.GetElementsByTagName("td")(0).GetElementsByTagName("p")
    Dim tds1 = tr.GetElementsByTagName("td")(0).GetElementsByTagName("p")(0).GetElementsByTagName("a")
    biaoti = tds1(0).innerhtml
    neirong = tds(1).innerhtml
    Dim dr111 As DataRow = DataTables("猪八戒").Find("标题 = \'" & biaoti & "\' and 内容 = \'" & neirong & "\'")
    If dr111 IsNot Nothing Then \'如果找到的话
    Else
        Tables("猪八戒").AddNew()
        Tables("猪八戒").Current("录入时间") = Date.Today()
        Tables("猪八戒").Current("标题") = biaoti
        Tables("猪八戒").Current("内容") = neirong
        Tables("猪八戒").Current("信息状态") = "未发送"
    End If
Next
DataTables("猪八戒").Save()

Dim drs As List(Of DataRow)
Dim txt As String = ""
drs = DataTables("猪八戒").Select("[信息状态] = \'未发送\'")
For Each dr As DataRow In drs
    dr("信息状态") = "已发送"
    biaoti = dr("标题")
    biaoti = biaoti.Replace("+","").Replace("^","").Replace("%","").Replace("~","").Replace("(","").Replace(")","").Replace("[","").Replace("]","")
    neirong = dr("内容")
    neirong = neirong.Replace("+","").Replace("^","").Replace("%","").Replace("~","").Replace("(","").Replace(")","").Replace("[","").Replace("]","")
    txt = txt & "名称:" & biaoti & vblf
    txt = txt & "内容:" & neirong & vblf
Next
DataTables("猪八戒").Save()
If txt <> "" Then
    txt = txt & vbcr
    \'txt = txt & "%(c)"
    Dim Proc As New Process
    Proc.File = "tencent://Message/?menu=yes&exe=&uin=38585830"   \'红色部分为QQ号
    Proc.Start()
    System.Threading.Thread.Sleep(2000)
    Sendkeys.Send(txt)
End If

--  作者:智友软件工作室
--  发布时间:2016/10/22 10:31:00
--  

图片点击可在新窗口打开查看此主题相关图片如下:qq截图20161022103048.png
图片点击可在新窗口打开查看

--  作者:有点蓝
--  发布时间:2016/10/22 11:05:00
--  
1、代码最后调用一下:
web.Dispose()
GC.Collect()

2、另外密集数据表格的操作,看看