Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Memory leak with disconnected recordsets.
Message
From
30/05/2001 12:28:09
 
 
To
30/05/2001 12:23:20
David Bennett
AdvoCare International LLC
Carrollton, Texas, United States
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00512735
Message ID:
00512741
Views:
13
Hi!

Try following loop:
FOR i = 1 TO 10000
    rs = CREATEOBJECT("ADODB.RECORDSET")
    WAIT WINDOW LTRIM(STR(i)) NOWAIT
    rs.ActiveConnection = oc
    rs.Open("SELECT getdate()")
    rs.ActiveConnection = .NULL. && Comment to plug the leak.
    rs.Close()
    release rs
ENDFOR
If this do not help, try also to include the sys(1104) function call after rs.Close(). This function purges the unused VFP memory inside of VFP.

HTH.

>Hey guys, I've already posted this to microsoft.public.fox.programmer.exchange. I hope you don't mind...
>
>Anyway, I'd been having a memory leak problem and finally narrowed it down to the following code snippet:
>
>
>LOCAL oc, rs, i
>oc = CREATEOBJECT("ADODB.CONNECTION")
>oc.CursorLocation = 3 && ADUSECLIENT
>oc.Open("Provider=SQLOLEDB;Data Source=SQLSERVER;" + ;
>        "Database=pubs;User ID=sa;Password=;")
>rs = CREATEOBJECT("ADODB.RECORDSET")
>FOR i = 1 TO 10000
>    WAIT WINDOW LTRIM(STR(i)) NOWAIT
>    rs.ActiveConnection = oc
>    rs.Open("SELECT getdate()")
>    rs.ActiveConnection = .NULL. && Comment to plug the leak.
>    rs.Close()
>ENDFOR
>oc.Close()
>
>
>If you load up Performance Monitor and watch the Private Bytes of the VFP6 process, you'll see the memory usage skyrocket and never go back down. If you then comment out the line that disconnects the recordset (rs.ActiveConnection = .NULL.), the leak stops. Now, the exact same code in VB doesn't leak memory. So I'm pretty sure it's a VFP only thing. I've tested on VFP SP3/SP4/SP5, MDAC 2.5/2.6 running on both WIN2K SP2 and WINNT SP6. It appears to have been around for a long time. Has anyone else encountered this?
>
>- david
Vlad Grynchyshyn, Project Manager, MCP
vgryn@yahoo.com
ICQ #10709245
The professional level of programmer could be determined by level of stupidity of his/her bugs

It is not appropriate to say that question is "foolish". There could be only foolish answers. Everybody passed period of time when knows nothing about something.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform