Server keeps increasing memory use

The Big Question

Before you get lost in debugging, it’s worth asking: Is this really an issue?

“My app uses lots of memory” is not really a viable issue, IMHO. I accepted a while ago that Java apps (and, by extension, CFML apps) will never be the lightest in the room, but we can make up for it in power and concurrency. An OutOfMemory exception doesn’t mean you have a memory leak, it just means your app is using more memory than allotted.

My guess is that you are setting an artificially low memory limit (a newer machine with less RAM? tut tut!), then frustrating yourself when a ColdBox-on-AdobeCF-on-Java app can’t run that.

You need to install Fusion Reactor, fire up JMeter and run 100 - 500 requests against your app with up to 10 concurrent hits. Watch the memory usage. The memory should naturally go up as the app does its thing, then drop back down when the garbage collector (eventually) kicks in and does its thing. If the memory goes up rapidly with each request, never drops significantly, and tops out quite quickly with even a sizable allotted memory (I’d guess at least 2GB) then we have a problem. Until then, I’m a bit skeptic.

As one last comment… didn’t we just help you out in piping static assets through CFML? Here’s a relevant piece of my thoughts on that topic:

Note that serving images through CFML should not be done lightly. I’m thinking you’d see a dramatic decrease in image download speed, an increase in cfml/java memory usage, and an overall decrease in other page performance. (Because page rendering now has to compete with image serving for the same amount of RAM allocated to the JVM.)

So, does this homepage serve images or other assets through CFML?

Debugging Tips

So my question to the community is, am I on the right track? Should I be looking to find instances of where models/modules/variables are declared more than they need to be if I keep adding memory usage every time the page is hit?

In my (uneducated) opinion, you may be barking up the wrong tree. You’re focusing on your own code and ColdBox instantiation because it’s familiar to you, and I get it… that’s a natural tendency. But memory leaks are extremely difficult to track down, and they could be coming from anywhere in the stack. Don’t get stuck on the top 3-5 layers of CFML.

Before you get too far in the weeds with debugging your (very minimal) homepage, I would advise stepping back to see the big picture:

  1. Are there any long-running jobs or other CFML apps on this same application? Is this homepage the only CFML code running on this java instance?
  2. Do you have any .jar files or other java libraries being loaded on request or on startup?
  3. Do you have ORM enabled?
  4. Why are you only seeing this issue after changing machines?
  5. What are the resource limits we’re talking about here?
  6. Are you sure your ColdBox bootstrap code in onRequestStart() and onApplicationStart() is correct? What about the shutdown code?

These are just the vague questions I have when I see high memory usage in what looks like a basic ColdBox app (No offense intended here! :smile: ). You didn’t exactly ask for help, so I won’t bother asking for more details, like the JRE version, CF engine/version, ColdBox version, etc.

PS.

I hope this doesn’t come across as I-Know-Best… because I certainly don’t. :slight_smile: IMHO it’s much cheaper and easier to increase the RAM usage and get back to writing code/ making :moneybag::moneybag::moneybag:. Unless you have a memory leak, in which case no amount of RAM is enough! :scream: And then yes, let’s optimize the ColdBox startup as much as possible.

2 Likes