Solved

java garbage collect

Posted on 1997-11-17
2
182 Views
Last Modified: 2010-04-16
I use jvc(just-in-time) compile my program, and use jview to run it.
can I forbid garbage collect to happen until program run out of memory.
I put one System.gc in different place in my program, why does it cost very different runing time in the same program(9 class).
 
0
Comment
Question by:yijun
2 Comments
 
LVL 4

Accepted Solution

by:
russgold earned 50 total points
ID: 1230731
You cannot generally control garbage collection in a system with automatic garbage collection (AG), such as Java.  This is one reason many people don't like AG in real-time systems.  The behavior is simply not predictable.

The normal behavior for most Java VM's is to delay all gc activity until it runs out of memory - or Runtime.gc() is called.
You can take advantage of this fact by adding calls to Runtime.gc() at various non-time-critical points in your system to ensure that a large backlog of unreferenced objects never develops.  Your behavior will still not be entirely predictable, but it should never get to be a problem.
0
 

Author Comment

by:yijun
ID: 1230732
Hi, thanks!
But how to delay gc happen until using out of memory?
0

Featured Post

NAS Cloud Backup Strategies

This article explains backup scenarios when using network storage. We review the so-called “3-2-1 strategy” and summarize the methods you can use to send NAS data to the cloud

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Protect jar file - windows app 2 53
javap bin 2 35
ejb on wildfly 5 20
String array comparison 4 34
Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
The viewer will learn how to implement Singleton Design Pattern in Java.
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question