Skip to main content
gamedev.net
🔒 Locked

[java] Garbage collection

Started by Spyder 7 replies 850+ views
Original Post
Spyder
Spyder
Is there a way to debug how many references exist to an object? Something like System.ObjectRef( object ); [edited by - spyder on January 14, 2003 3:55:06 PM]
Soulice
Soulice
If you are trying to do this to force Garbage Collection, wont work. Garbage Collection in java is handled by the VM and you can only ''suggest'' it to occur in your apps.

-Soulice
-Soulice
CaptainJester
CaptainJester
You need to build that yourself. Create a static variable that is initialized to 0 and is increased every time the constructor is called. Then you decrease it every time finalize() is called. Finalize is called by the garbage collector.



First make it work,
then make it fast.

--Brian Kernighan

"I’m happy to share what I can, because I’m in it for the love of programming. The Ferraris are just gravy, honest!" --John Carmack: Forward to Graphics Programming Black Book
"None of us learn in a vacuum; we all stand on the shoulders of giants such as Wirth and Knuth and thousands of others. Lend your shoulders to building the future!" - Michael Abrash[JavaGaming.org][The Java Tutorial][Slick][LWJGL][
evil sausage
evil sausage

        
//Spyder, get rid of the "<object>" in your post. It is being

//interpreted as an html tag and messing up the page.

//This was put in source tags to prevent further problems.



[edited by - evil sausage on January 11, 2003 8:25:58 PM]

[edited by - evil sausage on January 11, 2003 8:26:16 PM]

[edited by - evil sausage on January 11, 2003 8:26:31 PM]
And so, the evil religion thread stole the wonderful "What the Heck?" thread's throne. Truly a sad day for gamedev.
Spyder
Spyder
I''m not trying to force garbage collection, merely trying to find a smart way to keep track of all references to an object so that I can nullify them.
NuffSaid
NuffSaid
Why do you need to nullify the objects in the first place?
==========================================In a team, you either lead, follow or GET OUT OF THE WAY.
Spyder
Spyder
I need to nullify all references to the object.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.