PROBLEM
Memory usage increases while iterating over rows/features in a nonrecycling cursor when in an edit session.
Code:
pWorkspaceEdit.StartEditing True
Set pCursor = pTable.Search(Nothing, False)
Set pRow = pCursor.NextRow
Do Until pRow Is Nothing
'Memory is accumulated for each row
Set pRow = pCursor.NextRow
Loop
Set pCursor = Nothing 'Memory is freed
The cursor maintains a reference to each row that it has iterated over. It holds these objects in memory until the cursor is released, at which point the rows are released. Only then is memory deallocated for the rows that are no longer referenced by anything in the system.
Code:
pWorkspaceEdit.StartEditing True
Set pCursor = pTable.Search(Nothing, True)
Set pRow = pCursor.NextRow
Do Until pRow Is Nothing
'The same row object is used over again.
'No additional memory is used.
Set pRow = pCursor.NextRow
Loop
Set pCursor = Nothing
Article ID: 000006179
Get help from ArcGIS experts
Download the Esri Support App