How much Carbage-Collection does Xojo do by itself?
Do you have to destroy object-instances before reusing them?
And if so, how it’s been done?
I’m asking because we have some strange issues with long running WebApps (CGI or standalone).
Inside I’m reusing database objects (MySQL) and some PDF-Rendering instances.
For the DB-Connection I use a function inside the session, that returns a connected db-object.
dim db as new mysqlcommunityserver
db = session.dbConnect()
...
...
db.close()
It might be more helpful if you described the problems you’re experiencing. In general, Xojo garbage collection only happens when all references to an object are set to nil. Once this happens, the object is destroyed when the garbage collection routines runs.
Xojo does not do Garbage Collection, per se. Xojo uses reference counting and destroys the object as soon as the count goes to zero, in-line, real time. There is no garbage collection happening in the background. This means, however, that if you create circular references, the count will never go to zero and the memory will never be freed up.
And, if you really, really feel you need to do something like that, lookup WeakRef in the Language Reference, and use that instead of a regular reference…
create it once when the session starts & reuse it over & over in that session only
keep it as a property on the session itself
you probably do not want to share them across sessions at all
A terminology question, then: what does one call Xojo’s memory management system? I’ve been calling it a reference counting garbage collector for years.
In my experience, when it comes to memory management, the simplest solution is the best! I got confused and ran into problems with GC in Xcode and have heard several times, one of Android’s main causes of slowness is the Garbage Collection. But then AFAIK, Android apps are Java based, which also makes them slower by nature.