Memory Management

Post here your questions about SFS2X. Here we discuss all server-side matters. For client API questions see the dedicated forums.

Moderators: Lapo, Bax

Post Reply
smilefr
Posts: 58
Joined: 23 Mar 2009, 16:50
Location: France

Memory Management

Post by smilefr »

I know java has a garbage collector, but i don't really know how it behaves;

For example if i have an SFSObject A that contains an SFSObject B inside it, and a String "Hello" inside B, If i do:

(we assume "key of B" is the index of B)

Code: Select all

A.removeElement("Key of B")
Is "Hello" still somewhere inside the Memory? Or will the garbage collector remove it since it has no link?

Thank you,

smilefr
tchen
Posts: 191
Joined: 11 Dec 2010, 14:14

Post by tchen »

When nothing can see it, it'll be removed - maybe.

The GC has a couple generations. When something goes out of scope and it can readily determine nothing has a reference, it'll collect it almost instantly.

If it can't easily determine it, it starts to get moved into a older generation. As it gets older, it needs a hard-core mark-and-sweep collector. That's what you see when the JVM memory usage suddenly drops from the peak to the trough in the SFS admin panel.

So, depending on which generation it is in, you may or may not see it get removed :P
Post Reply