Skip navigation
s.filipowicz
Currently Being Moderated

JVM Heap size settings

Jun 21, 2012 4:29 AM

Tags: #coldfusion #jvm #heap_size

Recently I got a VPS server and I'm running Coldfusion, the website was running fine until it got more and more traffic and I started to encounter 'OutOfMemory' exceptions.

I thought simply to rise the memory of the VPS server, but this didn't help.

After doing some Google searches I found a setting in de CF Admin settings to set the JVM Heap memory. It was on the standard: Max Heap size 512MB and Min Heap size was empty. After playing around a bit I have now set it to Min 50MB and Max 200MB, good things is that I'm not getting the 'OutOfMemory' exceptions anymore. So far so good!

But with about 50 active visitors on the website, the website starts to get slow. The CPU usage is only about 8% (Windows Taskmanager), also the taskmanager show only about 30% of the 3GB RAM in use.

So I'm thinking that my values could be tweaked to use more of the RAM. Honestly I don't understand these JVM Memory heap settings, so I have no clue what is a good setting for me.

I found a CF script that displays the memory usage, the details are:

 

Heap Memory Usage - Committed    194 MB 
Heap Memory Usage - Initial  50.0 MB
Heap Memory Usage - Max  194 MB
Heap Memory Usage - Used     163 MB
JVM
- Free Memory    31.2 MB
JVM
- Max Memory     194 MB
JVM
- Total Memory   194 MB
JVM
- Used Memory    163 MB
Memory Pool - Code Cache - Used  13.0 MB
Memory Pool - PS Eden Space - Used   6.75 MB
Memory Pool - PS Old Gen - Used  155 MB
Memory Pool - PS Perm Gen - Used     64.2 MB
Memory Pool - PS Survivor Space - Used   1.07 MB
Non-Heap Memory Usage - Committed    77.4 MB
Non-Heap Memory Usage - Initial  18.3 MB
Non-Heap Memory Usage - Max  240 MB
Non-Heap Memory Usage - Used     77.2 MB
Free Allocated Memory: 30mb
Total Memory Allocated: 194mb
Max Memory Available to JVM: 194mb
% of Free Allocated Memory: 16%
% of Available Memory Allocated: 100%

 

My JVM arguments are:

-server -Dsun.io.useCanonCaches=false -XX:MaxPermSize=192m -XX:+UseParallelGC -     Dcoldfusion.rootDir={application.home}/../ -Dcoldfusion.libPath={application.home}/../lib

Can I give the JVM more memory? If so, what settings should I use?

Thanks very much!!



 
Replies
  • Currently Being Moderated
    Jun 21, 2012 10:38 AM   in reply to s.filipowicz

    Yes you can give the JVM more memory if you are only using 1GB out of the 3 GB on your server. I would set the max heap size (in cf administrator) to 1024mb (1gb) instead of 200mb. If you are running 64 bit then you can go above 1gb, but if you are running 32 bit you can't get the max heap. You might consider setting the min heap size equivalent to or just below the max heap size, so you aren't wasting resources shrinking or growing the heap at runtime.  It's also worth noting that the slowness you are experiencing under load may not have anything to do with the heap size. The problem could be on the DB side of things, or elsewhere.

     

    --

    Pete Freitag

    Foundeo Inc. | HackMyCF.com

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 12:35 PM   in reply to Peter Freitag

    Just to add to Pete’s note, I didn’t see anything in s.filipowicz’s note that said he was running 32-bit, so let’s clarify to readers that Pete’s first 2 sentences refer to that specifically. (His third sentence implies it, but I just want to be clear.)

     

    Also, s.filipowicz, you say you got “outofmemory” errors, but you don’t say what kind. There is a big difference between an OOM error that then says it’s related to “heap space”, versus one that says it’s related to “permgen”, or “out of swap space”, or “unable to create new native thread”. The latter three may well mean that you need to lower the heap, believe it or not. 

     

    Sometimes, the higher the heap the greater the contention with other things that leads especially to the “out of swap” or “new native thread” error. The “permgen” error generally means you need to increase the maxpermsize, but that’s not always clear—sometimes you need to fix the problem that’s stressing the permgen.

     

    And indeed, you say that lowering the heap max made the errors go away, but performance got bad. One may suspect that you were then having something other than an “OOM heap space” error, and that lowering the heap made that go away. But then it could just be that whatever caused that error then is not happening since you restarted—and it may come back, so you may well still need to increase the heap.

     

    Sadly, this subject is a lot more complex than you will generally find discussed on most blogs and even many Java resources. I started to address it as a blog entry here:

     

    CF911: Lies, damned lies, and when memory problems not be at all what they seem, Part 1

    http://www.carehart.org/blog/client/index.cfm/2010/11/3/when_memory_pr oblems_arent_what_they_seem_part_1

     

    While I never have finished the additional parts of a series I had anticipated, the introductory info there (fairly substantial) may still be of value.

     

    Anyway, as a starting point, the key is to note which kind of OOM error you are getting when CF crashes, which as you may have found are discussed in the logs in the Re: JVM Heap size settings\runtime\logs\ dir (or Re: JVM Heap size settings\logs\), not the Re: JVM Heap size settings\logs viewable in the CF admin. Let us know what you find.

     

     

     

    /charlie

     
    |
    Mark as:
  • Currently Being Moderated
    Jun 21, 2012 4:00 PM   in reply to s.filipowicz

    From the JVM usage listed Heap maximum is 200Mb with 160Mb used only leaving 30Mb free. It is conceivable that 30Mb can be utilised or committed with objects quite easily.

     

    JVM - Free Memory    31.2 MB

    JVM - Max Memory     194 MB

    JVM - Total Memory   194 MB

    JVM - Used Memory    163 MB

     

     

    Does not look like PermGen (-XX:MaxPermSize=192m) is being stressed:

     

    PS Perm Gen - Used     64.2 MB

     

    Having said that, setting an initial value to PermGen can benefit JVM performance eg -XX:PermSize=96m (the value could differ give more samples of JVM usage over time)

     

    Ditto to other posters I also expect you can benefit by having a bigger maximum heap defined. While changing heap settings it can be a good idea to set a minimum setting.

     

    CFadmin > Server Settings > Java and JVM

     

    Minimum JVM Heap Size (MB)  512      Maximum JVM Heap Size (MB)  1024  

     

     

    HTH, Carl. 

     
    |
    Mark as:

More Like This

  • Retrieving data ...

Bookmarked By (0)

Answers + Points = Status

  • 10 points awarded for Correct Answers
  • 5 points awarded for Helpful Answers
  • 10,000+ points
  • 1,001-10,000 points
  • 501-1,000 points
  • 5-500 points