1

在我的公司,我们最近遇到了一些内存问题。我们所做的一件事是增加了 JRUN 中的堆大小,但现在我们注意到了一些副作用。

其中之一是处理图像的 CFX 标签。当我们使用它时,它有时无法加载我们给它的文件。我们目前的想法是,为了处理图像,必须将整个图像加载到内存中。它似乎只会在大文件上引发错误,这需要 200+ MB 的内存来存储整个文件。

我想知道的是 Coldfusion 如何处理 CFX 标签加载和执行。由于特别是 CFX 标签是用 C++ 编写的,我认为它不一定会使用 Coldfusion 堆(因为它只存储 Java 数据),并且在处理某些内容时我们不会看到堆峰值。

我想主要的问题是 CFX 是如何执行的:它是作为 JRUN 下的线程运行,还是创建了一个在自己的用户空间中运行的本机 Windows 进程?而且,如果它确实在JRUN下运行,那么它在执行时占用了多少内存空间,有没有办法对其进行监控?

4

2 回答 2

1

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.

于 2012-05-19T06:07:56.843 回答
1

CFX 绝对作为 JRUN 下的线程运行,并且数据通过 JNI 层从 Java 编组到 C++。所以是的,它将使用默认文件打开/读取(在幕后)将整个图像加载到堆中,然后将二进制文件传递给您的 C++ 标记。在我看来,处理大图像文件(或一般的大文件)一直是 CF 的一个问题。有一些用于图像处理的“纯 Java”解决方案可以提供更好的性能 - 或者您可以使用诸如“imagemagik”之类的东西,它将文件名和路径传递给 shell 并单独执行。这是我的看法。

于 2012-05-18T18:25:19.233 回答