aspose file tools*
The moose likes Performance and the fly likes java program goes to the end but the GC is still working. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Performance
Bookmark "java program goes to the end but the GC is still working." Watch "java program goes to the end but the GC is still working." New topic
Author

java program goes to the end but the GC is still working.

Benson Fung
Ranch Hand

Joined: Apr 10, 2003
Posts: 207
Hi,

I have a strange problem about the GC.

The program is a long live process with start time and end time. I executes the program using java -verbose:gc [Java class]. Once the program reaches end time, the program will go to the end. However, it looks like it doesn't go to the end because I still can see the GC message keeps coming out, i.e. [GC 892K->339K(5056K), 0.0023834 secs].

Please suggest what is going on.


Thanks
Deepak Bala
Bartender

Joined: Feb 24, 2006
Posts: 6661
    
    5

May be the GC cycle ran after your program completed and released references to objects ? Why is this a problem ?


SCJP 6 articles - SCJP 5/6 mock exams - More SCJP Mocks
Benson Fung
Ranch Hand

Joined: Apr 10, 2003
Posts: 207
Because suppose the program is supposed to the end after the last line of code. However, the GC log message is still displaying.
Like :

Class XXX {

public static main(String args[]) {
while(true) {
//loop
}

System.out.println("End");
}


If End is printed, that means the program is going to the end, but the GC message is still displaying. I think this is absolutely problem, right?


Please help

Viktor Kubinec
Ranch Hand

Joined: Jan 28, 2012
Posts: 34
Java application process doesn't end when main method is completed. It ends when all threads are completed. I don't know what are you doing in your while loop but if new Threads were started there this could be the reason.
Benson Fung
Ranch Hand

Joined: Apr 10, 2003
Posts: 207
Thanks for your valuable information, Viktor.

Let me give more information. What the loop does is

1. Use Runtime.exec to execute another java process
2. At the same time it creates two threads to monitor the above process Error Stream and Input Stream. The thread looks like the following :





Please help


Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: java program goes to the end but the GC is still working.