• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

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

 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
May be the GC cycle ran after your program completed and released references to objects ? Why is this a problem ?
 
Benson Fung
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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

 
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
reply
    Bookmark Topic Watch Topic
  • New Topic