• 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
  • paul wheaton
  • Tim Cooke
  • Paul Clapham
  • Henry Wong
Sheriffs:
  • Ron McLeod
  • Jeanne Boyarsky
Saloon Keepers:
  • Roland Mueller
  • Tim Holloway
  • Piet Souris
Bartenders:

freeing memory of JVM

 
Ranch Hand
Posts: 67
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I have a batch file doing the following thing ---
************
java MyApp arg_1
java MyApp arg_2
...
...
java MyApp arg_99
java MyApp arg_100
*************
I found the speed was fast in the beginning but it significantly slows down when it reaches "java MyApp arg_80". SInce each "java MyApp. . .." invokes a new JVM, I suspect that when the batch file reaches "java MyApp arg_80" some previously created JVM have NOT been really cleaned up in the memory yet, i.e. some of the previously created JVM are still occupying the memory space so the memory is gradually occupied fully, and this causes the slowing down of the newly created JVM.
Does this make sense ? I am not sure. Theoretically when a "java MyApp arg_n" is done, the OS should free the memory it occupies, right ? So, does what I said in last paragraph make sense ?
Thanks,
steve
 
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
The only solution to this kind of scenario depends on
One solution would be enhancing the RAM and calling GC would not be of much help because there is no guarantee that GC would get invoked when u call it. I read some where that we can edit some parameters for GC so when and object is called a specified "n" # of times GC kicks in and performs the clean up. Try to grab some article on GC. It should help you.

Cheers,
Gaya3
---------------------------------
Prasanna Kumar R.v
 
Ranch Hand
Posts: 862
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is there any way you can design the program so it can run your programs as threads within 1 JVM? This would consume far less memory than loading 100 JVMs. You could either pass your args like:
java MyClass arg1, arg2
or read the input from a file
java MyClass myfile.dat
steve - http://www.jamonapi.com
 
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for the reply. I will consider modifying the code. But I still want to confirm this ---
After the system finishes executing "java MyApp arg_n" and starts moving to the next "java MyApp arg_n+1", since the first pgm is done, will the system immediately free its memory or not ?
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Gayathri Prasad:
One solution would be enhancing the RAM and calling GC would not be of much help because there is no guarantee that GC would get invoked when u call it.


GC'ing doesn't give back memory to the OS.
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Steve Mutanson:
Does this make sense ? I am not sure. Theoretically when a "java MyApp arg_n" is done, the OS should free the memory it occupies, right ? So, does what I said in last paragraph make sense ?


I am not sure.
I get it that you are using Windows? Take a look at the middle tab of the Taskmanager (processes?). There you should be able to see which processes are eating up your memory.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Remember that his has nothing to do with GC, which
takes place inside an executing java process. Here
we start a number of separate java processes, each
with its own GC thread.
This is a matter of how long each Java process executes,
how much memory each process uses,
and how the OS handles that memory. Probably java processes
n-1, n-2,... have not finished execution before process n
starts. If there are several processes executing at the
same time and they each use quite a lot of memory, of
course the OS will have a hard time. It will probabaly
swap pages to disk which makes everything slower.
I would add a println() with a unique identifier at the
first and last line in the main method to see if there
are several processes executing at the same time.
Joakim
 
An elephant? An actual elephant. Into the apartment. How is the floor still here. Hold this tiny ad:
Clean our rivers and oceans from home
https://www.kickstarter.com/projects/paulwheaton/willow-feeders
reply
    Bookmark Topic Watch Topic
  • New Topic