I used the OLE Control of pb10 and IE as an embedded browser,
Execute some simple URL calls (using the navigator2 function) and page parsing.
This ole control is in the window. I found some problems:
1. After the window is closed, the memory will not be released. As a result, it will consume about 50 MB of memory after a page is opened.
2. the navigator2 function is called multiple times in the OLE component to open a new page. The memory consumption increases constantly. 20 call cycles consume more than 100 MB of memory, and it is estimated that multiple pages are cached in it, how to clear it?
3. Call the navigator2 function for the OLE component in the loop. After the loop ends, the program will be terminated for no reason and the prompt is:
An error occurs in the aa.exe program and will be disabled by windows. You need to restart the program and create an error log.
The single-layer for next loop does not take any measures.
----------------------------------------------------------------------
Enthusiastic people
--------------------------------------------------------
Help you up
--------------------------------------------------------
I have done a simple program before. It seems that there is no such problem. Try other versions of Pb, such as pb804 and pb903. In addition, try not to use arrays. I have tried it before. Pb cannot release the memory applied for by arrays. Unless you close the entire program, you can create a userobject and open it with openuserobject, use colseuserobject () When closing ().
To traverse data, use the control [] attribute.
--------------------------------------------------------
I have a question. If you use this control to open a webpage, how can you determine whether the webpage is successfully opened, such as error 404,400? Thank you.
--------------------------------------------------------
Top
Going back upstairs, you may have a navigatecomplete2 event through the ole control. You can try writing code there;
However, I cannot obtain whether the page is fully loaded or not.
--------------------------------------------------------
To lzheng2001 (1 plus 1 ):
Thank you!
In fact, the collection elements in the webpage are basically arrays. I don't know if this is the reason,
However, you can try openuserobject.
--------------------------------------------------------
There is a way to stop the program from being closed. Do not operate the OLE Control in the application's Open events. After the application is opened,
Call from other places to delay the error time,
However, an error occurs when the application is closed.
Strange.
--------------------------------------------------------
Paste your code to see it
--------------------------------------------------------
I called an event of a timer object in the application open event. The code of this event is basically the same as that of the timer event of the timer object:
Event timer2 ()
If of_checkonline () =-1 then return // check whether the Internet is connected
This. Stop ()
Popmsg ('water timer2 ')
W_main.of_csdn_extcheck (IDs, defaultwait) // ultwait indicates that the wait time IDS is datastore
Popmsg ('close ')
This. Start (gi_csdn_extcheck)
--------------------------------------------------------
The main code is in w_main.of_csdn_extcheck ()
String ls_url, ls_null, ls_tables, ls_href, ls_status
Long li, LJ, li_row, ll, LK, li_rtn, li_count, li_find
Oleobject tables, table, rows, items
Any la_tables
Uo_ielu_ie1, lu_ie2, lu_ie3
Setnull (ls_null)
// Navigator
Popmsg ('read the home page ...')
Openuserobject (lu_ie1)
Ls_url = "http://community.csdn.net/Expert/ForumsList.asp? Typenum = 1 & roomid = 14"
Lu_ie1.ole_ie.object.navigate2 (ls_url, 0, ls_null, ls_null ,'')
// Wait for wait seconds
Wait (ai_wait)
// Split
Try
Tables = lu_ie1.ole_ie.object.document.body.getelementsbytagname ("table ")
Catch (nullobjecterror nullerr)
Popmsg2 (nullerr. getmessage ())
Closeuserobject (lu_ie1)
Return-1
Catch (oleruntimeerror oleerr)
Popmsg2 (oleerr. getmessage ())
Closeuserobject (lu_ie1)
Return-1
End try
// Set the new question to the old question
For LK = 1 to ads_ds.rowcount ()
Ls_status = ads_ds.getitemstring (LK, 'status ')
If ls_status = '0' then
Ads_ds.setitem (LK, 'status', '1 ')
End if
Next
Popmsg ('analyze the homepage ...')
For li = 1 to tables. Length
Rows = tables. item [Li-1]. Rows
For lj = 1 to rows. Length
Items = rows. item [LJ-1]
If INTEGER (items. cells. Length) <> 6 then continue
If trim (string (items. innertext) = 'Question user name score reply time' then continue
// Exclude indexed issues
Ls_href = string (items. cells [0]. Children (1). href)
Select count (*)
Into: li_count
From questiones
Where href =: ls_href
;
If sqlca. sqlcode =-1 then
Popmsg2 (sqlca. sqlerrtext)
Closeuserobject (lu_ie1)
Return-1
End if
If li_count> 0 Then exit
//?? Why are two identical connections parsed sometimes? Csdn problems?
Li_find = ads_ds.find ("href = '" + ls_href + "'", 1, ads_ds.rowcount ())
If li_find> 0 Then exit
// Insert new question
Li_row = ads_ds.insertrow (0)
Ads_ds.setitem (li_row, 'pout', "Expand topic ")
Ads_ds.setitem (li_row, 'Question ', string (items. cells [0]. innertext ))
Ads_ds.setitem (li_row, 'userid', string (items. cells [1]. innertext ))
Ads_ds.setitem (li_row, 'credentials', INTEGER (items. cells [2]. innertext ))
Ads_ds.setitem (li_row, 'response', INTEGER (items. cells [3]. innertext ))
Ads_ds.setitem (li_row, 'qtime', string (items. cells [4]. innertext ))
Ads_ds.setitem (li_row, 'href ', string (items. cells [0]. Children (1). href ))
Next
Next
// Save the modification
Li_rtn = ads_ds.update ()
If li_rtn =-1 then
Rollback;
Closeuserobject (lu_ie1)
Return-1
Else
Commit;
End if
// Re-sort
Ads_ds.sort ()
// Hide or show
W_csdn_qcheck.of_hide ()
// Automatic reply
Oleobject iframes, textareas
String frname, frsrc, temp, ls_value
Popmsg ('reply processing ...')
Try
For LK = 1 to ads_ds.rowcount ()
Ls_href = ads_ds.getitemstring (LK, 'href ')
Openuserobject (lu_ie2)
Lu_ie2.ole_ie.object.navigate2 (ls_href, 0, ls_null, ls_null ,'')
// Wait
Wait (ai_wait)
// Search for Frame
Iframes = lu_ie2.ole_ie.object.document.body.getelementsbytagname ("iframe ")
// Analysis
For li = iframes. length to 1 step-1
Frname = string (iframes. item [Li-1]. Name)
If frname = 'xmlreply' then
Frsrc = string (iframes. item [Li-1]. SRC)
Frsrc = trim (frsrc)
Exit
End if
Next
// Find the form
Openuserobject (lu_ie3)
Lu_ie3.ole_ie.object.navigate2 (gs_csdncomm + frsrc, 0, ls_null, ls_null ,'')
// Wait
Wait (ai_wait)
// Reply
Popmsg ('reply processing... '+ String (lk) +'/'+ String (ads_ds.rowcount ()))
Textareas = lu_ie3.ole_ie.object.document.getelementsbyname ("replycontent ")
If autoanswer (ls_value) =-1 then
Closeuserobject (lu_ie1)
Closeuserobject (lu_ie2)
Closeuserobject (lu_ie3)
Return-1
End if
Textareas. item [0]. value = ls_value
// Submit a reply
Lu_ie3.ole_ie.object.document.xmlreply.submit ()
// Transfer Problem
Update questiones
Set status = '2 ',
Status2 = '1'
Where href =: ls_href
;
If sqlca. sqlcode =-1 then
Rollback;
MSG (sqlca. sqlerrtext)
Closeuserobject (lu_ie1)
Closeuserobject (lu_ie2)
Closeuserobject (lu_ie3)
Return-1
End if
Commit;
Closeuserobject (lu_ie2)
Closeuserobject (lu_ie3)
Next
Catch (nullobjecterror nullerr2)
Popmsg2 (nullerr2.getmessage ())
Closeuserobject (lu_ie1)
Closeuserobject (lu_ie2)
Closeuserobject (lu_ie3)
Return-1
Catch (oleruntimeerror oleerr2)
Popmsg2 (oleerr2.getmessage ())
Closeuserobject (lu_ie1)
Closeuserobject (lu_ie2)
Closeuserobject (lu_ie3)
Return-1
End try
// Re-search
Ads_ds.retrieve ()
If isvalid (w_csdn_qcheck) Then w_csdn_qcheck.of_hide ()
Closeuserobject (lu_ie1)
Return 1
--------------------------------------------------------
I have time to try.
Is the memory problem solved by the landlord now? Is there a problem of disabling the service illegally?
--------------------------------------------------------
After openuserobject is used, it seems that the memory problem is slightly better. However, with multiple calls to the timer event, the memory will continue to increase, from to, and the memory usage will reach 90 MB, the virtual memory is 250 MB.
Generally, during the first timer event, the memory usage is about 50 MB, and the virtual memory is about 40 MB.
The problem of illegal shutdown is still present only when the system is closed, which has no impact on the system operation. In fact, I just removed the timer call from the application's Open events.
Dizzy.
--------------------------------------------------------
If you open a large number of pages, the memory usage will increase. Of course, if you close the page, you should release the memory occupied by the page theoretically. You can call garbagecollect () regularly to see if it is helpful.
I can use VB to test the problem by comparing it with Pb.
--------------------------------------------------------
Okay. Thank you!
--------------------------------------------------------
It is confirmed that garbagecollect () has no effect, and regular calls may cause no response to the application. Manual call is ineffective.
--------------------------------------------------------
I tested it with pb804 today and the memory is okay!
I used a webbrowser control and browsed more than 10 webpages. The memory can be recycled automatically without any problems found!
--------------------------------------------------------
Is it because of pb10.
Close the post.
--------------------------------------------------------
No! After creating an application, you have tried both pb8 and pb10. You can simply open a window and then open a webpage. After closing the window, the memory cannot be recycled.
--------------------------------------------------------
No! I use pb804. Do I dare to use Pb without patching! Don't joke.
--------------------------------------------------------
My 8.0.3 9704