Reputation: 1806
At my company, we have been running into some memory problems lately. One thing we have done is increased the heap size in JRUN, but now we are noticing some side effects.
One of which is a CFX tag that processes images. When we use it, it cannot load the files we give it sometimes. Our current idea is that in order to process images, the whole image must be loaded into memory. It only seems to throw errors on large files, which would take 200+ MB of memory to store the whole thing.
What I am wanting to know is how Coldfusion handles CFX tag loading and execution. Since the CFX tag in particular was written in C++, I would think that it wouldn't necessarily use the Coldfusion heap (as it only stores Java data), and we are not seeing heap spikes when we process something.
I guess the major question is how the CFX gets executed: does it run as a thread under JRUN, or does a native Windows process get created that runs in its own user space? And, if it does run under JRUN, what memory space does this use when executing, and is there a way to monitor it?
Upvotes: 1
Views: 353
Reputation: 5678
I think that if you're running a 32-bit process, it can only access 2gig. If the heap is 1gig, then non-heap memory will be 60-200+ meg, then add in memory for each thread the process is running (and the number of threads goes even higher when you're clustered) then there sometimes isn't that much memory space left in your process. Plus, as I understand it, various DLLs are mapped into your memory space somewhere in the upper part of the memory range, meaning that when your image processing tag attempts to allocate a very large block of contigous memory (outside of heap is my guess), there's no single block left for it. This answer is somewhat speculative, so don't take it as gospel, but it may be worth looking at programs which can visualise a processes' memory map.
Upvotes: 1
Reputation: 7193
A CFX definitely runs as a thread under JRUN and the data is marshalled from Java to C++ through the JNI layer. So yes it will load up the whole image into the heap using the default file open/read (under the covers) and then pass the binary to your C++ tag. Handling large image files (or large files in general) has always been an issue with CF in my view. There are some "pure Java" solutions for image handling that will provided for better performance - or you can use something like "imagemagik" which passes a filename and path to a shell and is executed separately. That's my take.
Upvotes: 1