Garbage Collection

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()

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.

I have to say that I seem to recall what Tim says, in the essence that Xojo doesn’t do any Garbage Collection.

And yes try to avoid circular references, (an object having another object as a property, with a property linking back to the original object).

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…

OK, so what’s the best way to get a reusable db-object in the session?

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.

I believe it’s simply called “Reference Counting”. I know Garbage Collection as the other method.

Sams correct - we simply use reference counting
Garbage collection is a different system - Java uses a garbage collector

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.

Check this one …Garbage Collection in Java