Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
BatchUpdateCount in CursorAdapter causes memory-leak
Message
From
17/02/2004 09:55:08
Reno Fiedermutz
Smartstream Technologies
Vienna, Austria
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
BatchUpdateCount in CursorAdapter causes memory-leak
Miscellaneous
Thread ID:
00877926
Message ID:
00877926
Views:
78
Whenever I use the property BatchUpdateCount for what it was intended - collect several SQL-Statements to send them as one single batchcommand to the server (SQLServer) - VFP executes fine, but never again and by no means releases the memory it allocated for the execution. Dealing with some millions of rows, VFP rather prefers to crash then to release the memory allocated.
Does anyone have similar experiences with BatchUpdateCount > 1 against SQL Server via ODBC?

I'm posting a sample code which assumes a table testtable in SQL Server with the fields one (primary),two,three, all integer:

LOCAL oCursorAdapter as CursorAdapter, cConnectionString as String

cConnectionString = "driver=SQL Server;server=lb-et-1;database=testdb;uid=sa;pwd=xxx;trusted_connection=no;"
* Shared connection to the DB
nHandle = SQLSTRINGCONNECT(cConnectionString,.T.)

oCursorAdapter = NEWOBJECT("CursorAdapter")
WITH oCursorAdapter
.Alias = "testcursor"
.DataSource = nHandle
.DataSourceType = "ODBC"
.SelectCmd = "SELECT one,two,three from testtable"
.Tables = "testtable"
.KeyFieldList = "one"
.UpdatableFieldList = "two,three"
.UpdateNameList = "one testtable.one,two testtable.two,three testtable.three"
.BufferModeOverride = 5
.FetchAsNeeded = .T.
.AllowDelete = .T.
.AllowInsert = .T.
.AllowUpdate = .T.
.BatchUpdateCount = 50
.FetchSize = -1
.SendUpdates = .T.
.WhereType = 1
ENDWITH

IF oCursorAdapter.CursorFill ()
SELECT testcursor
* do something with the data, so there will result some update-candidates
REPLACE ALL two WITH two + 1
REPLACE ALL three WITH three - 1
?SYS(1016) && memory before
TABLEUPDATE(.T.)
ELSE
LOCAL ARRAY aErrors[1]
AERROR(aErrors)
ENDIF
SQLDISCONNECT(nHandle)
RELEASE oCursorAdapter
CLOSE ALL
CLEAR all
?SYS(1016) && memory after: VFP did not deallocate and will not do it in subsequent executions
Reply
Map
View

Click here to load this message in the networking platform