prevent a garpage Collection

I

Ingo R. Homann

Hi,


Or... Yes - simply keep a reference to the Object you want to prevent
from being collected. :)

Or... Please describe your question in detail.

Ciao,
Ingo
 
M

Mark Space

Ingo said:
Hi,



Or... Yes - simply keep a reference to the Object you want to prevent
from being collected. :)

Or... Please describe your question in detail.

Go not to the Internet Elves for advice, for they will say both "WTF,
dude?!?" and "RTFM!!" ;-)
 
V

Velmurugan

Go not to the Internet Elves for advice, for they will say both "WTF,
dude?!?" and "RTFM!!" ;-)


hey
not in program
while running the program is there any option to prvent the garpage
collection daemon
it means i ma talking abt garpage collectioon daemon
 
I

Ingo R. Homann

Hi,
hey
not in program
while running the program is there any option to prvent the garpage
collection daemon
it means i ma talking abt garpage collectioon daemon

Then, the above answer is correct. The only possibility to influence the
GC is to use the commandline options and to call System.gc() (which does
the opposite of "preventing" gc).

Ciao,
Ingo
 
H

harborsparrow


Usually the GC daemon will only "take over" if the heap has become
full. Possibly this can be made to happen much less often by properly
disposing of objects as you go along. If you are creating really
large objects in the heap and not disposing them properly, the GC will
have to run.

You might need to profile your application to see if that is happening.
 
U

usenetuser

Hi,



Then, the above answer is correct. The only possibility to influence the
GC is to use the commandline options and to call System.gc() (which does
the opposite of "preventing" gc).

Ciao,
Ingo

Of course, System.gc() only *suggests* to the virtual machine that you
want the garbage collector to run at that point -- the vm doesn't
actually have to do it then, or reclaim all unreferenced memory.
 
L

Lew

harborsparrow said:
Usually the GC daemon will only "take over" if the heap has become
full. Possibly this can be made to happen much less often by properly
disposing of objects as you go along. If you are creating really
large objects in the heap and not disposing them properly, the GC will
have to run.

Meaningless advice. Disposing of objects "properly" or not has no effect on
how often GC runs, only on how much it reclaims when it does.

In fact the programmer cannot "dispose" of objects in any case, only
dereference them. It is the GC that disposes of the objects.

The GC runs when heap gets cramped, which happens from the /creation/ of objects.

The only way to try to prevent GC from running is not to create objects, which
of course, is silly.

-- Lew
 
O

Oliver Wong

Ingo R. Homann said:
Hi,


Then, the above answer is correct. The only possibility to influence the
GC is to use the commandline options and to call System.gc() (which does
the opposite of "preventing" gc).

Perhaps you could run the VM in debugging mode, and then find the GC
thread, and pause it indefinitely (this is assuming your VM implementation
actually dedicates an entire thread to the GC, and promises not to do any
GC-ing in other threads).

- Oliver
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,681
Members
48,796
Latest member
Greg L.

Latest Threads

Top