on 07-27-2006 3:48 PM
hi,
how often do i have to delete my objects ? Do i have to delete the objects within my sub like as follows or is it ok when i delete all object when my addon will exit?
private sub x()
Dim oRec As SAPbobsCOM.Recordset
oRec = moSBOCompany.GetBusinessObject(SAPbobsCOM.BoObjectTypes.BoRecordset)
...
'delete objects
System.Runtime.InteropServices.Marshal.ReleaseComObject(oRec)
oRec = Nothing
GC.Collect() 'Call the garbage collector for good measure
GC.WaitForPendingFinalizers()
end sub
thanks
Markus
Hi Markus,
Technically I don't know the answer to your question, but it makes more sense to free resources and delete your objects as soon as you don't use them anymore, like you specified in your code below. Freeing only when you close the application might be difficult to manage and also means that most of your variables will have to be declared as global. Every time you instanciate a new object you take up memory and if you don't free it, your application will be a memory collector.
Hope it helps,
Adele
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
7 | |
6 | |
4 | |
3 | |
3 | |
3 | |
3 | |
3 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.