• 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 Clapham
  • Tim Cooke
  • Jeanne Boyarsky
  • Liutauras Vilda
Sheriffs:
  • Frank Carver
  • Henry Wong
  • Ron McLeod
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Piet Souris
  • Himai Minh

memory restriction

 
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How do you restrict your java application to only use at most 128
megabytes of memory
 
author and iconoclast
Posts: 24204
44
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Sun's JVMs use a fixed-sized heap (or at least, a heap that will grow only to a predetermined maximum size.) The default is 64MB for most releases. The total process size is bigger than that because that's only the heap available for Java objects, about 80MB total. The -mxNNm command-line switch sets the max heap size to NN megabytes. To limit to 128MB total RAM, something like -mx110m would do it.
 
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 Ernest Friedman-Hill:
To limit to 128MB total RAM, something like -mx110m would do it.



I'd expect that to use more than 128MB in total. But that depends on a lot of factors, for example:

How big is the byte code of the program? That influences how big the permanent generation becomes, which resides outside the regular heap.

How many threads are started by the program? Every thread gets its own stack, which of course uses memory.

On which platform runs the program? That influences how big each thread's stack might become.

In the end, you will need to do some experimentation with your specific application, on the platform you are interested in.

If you are using a Java 5 runtime environment, you should use the jconsole application to get a view on how much memory is used for what.
 
Sue Meng
Ranch Hand
Posts: 137
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks guys. I beleive tread stacktrace is the factor that may afect the use of memory.
 
And will you succeed? Yes you will indeed! (98 and 3/4 % guaranteed) - Seuss. tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic