Select to view content in your preferred language

How to close an SDE connection

1091
4
02-14-2011 11:29 AM
VuDang
by
Emerging Contributor
Hello,

Is there a proper way to close an SDE connection or just let the IWorkspace garbage collected by .NET.  What we have is an IWorkspace to an SDE that we start and edit session, made some edits, stopped the operation, stopped edit session.  At this point should we issue another command to close the IWorkspace?

Currently, in our Oracle database the SDE.states table grows by one record for every edit session that is opened and these records stay after the edit session is stopped.

Thanks,
Vu
0 Kudos
4 Replies
Venkata_RaoTammineni
Regular Contributor
Hello,

Is there a proper way to close an SDE connection or just let the IWorkspace garbage collected by .NET.  What we have is an IWorkspace to an SDE that we start and edit session, made some edits, stopped the operation, stopped edit session.  At this point should we issue another command to close the IWorkspace?

Currently, in our Oracle database the SDE.states table grows by one record for every edit session that is opened and these records stay after the edit session is stopped.

Thanks,
Vu


Its not like normal database.. something like close and open the connection..once done with start and stop edit sessions ... that is done..
0 Kudos
JonHall
Frequent Contributor
... should we issue another command to close the IWorkspace?


pWorkspace = Nothing
0 Kudos
AlexanderGray
Honored Contributor
Use the comReleaser object when you are done.  You have to use it on the cursors, tables, featureclasses, features,  rows,  cursors etc. or else you will still have objects with a connection open.  It is actually quite tricky.  Even if you just access a object through the property of another object, will will end up with a reference to that object in memory not assigned to a variable...  Make sure you assign these to a variable so you can release it later.  I like to make a using block with a new comreleaser and add all the variables to the be managed by the comreleaser, when the using block end the comreleaser gets destroyed and releases all the references it manages.
0 Kudos
JonHall
Frequent Contributor
...the SDE.states table grows by one record for every edit session that is opened and these records stay after the edit session is stopped.


Isn't this normal when editing a versioned database? 

Have you run ArcCatalog (ArcToolbox > data management > database > ) COMPRESS, then checked the sde_states table ? 

Are you editing in the Default version? If not, you may need to reconcile, post the edits in your Version, delete the Version, then run Compress...

If Compress isn't removing sde_States records that you think are unreferenced, then maybe they are still referenced. Have your DBA check that COMPRESS moved all the A & D records to the base tables, and that no A or D table records that still reference that SDE-State_ID. If the A& D table records are still there, then have the DBA check if locks are beingleft open.

What version of ArcSDE Enterprise are you connecting to?

Unlike ADO connections, there is no .close method.

I think it will solve your problems if you set the workspace = nothing, and have your DBA set up a regularly scheduled automatic Compress
0 Kudos