?
Solved

java garbage collect

Posted on 1997-11-17
2
Medium Priority
?
187 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 4

Accepted Solution

by:
russgold earned 150 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Basic understanding on "OO- Object Orientation" is needed for designing a logical solution to solve a problem. Basic OOAD is a prerequisite for a coder to ensure that they follow the basic design of OO. This would help developers to understand the b…
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
Suggested Courses
Course of the Month12 days, 18 hours left to enroll

777 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