简体   繁体   English

Domino JVM 内存和 POI

[英]Domino JVM memory and POI

I have an agent which exports notes document to excel (xlsm) using Apache POI.我有一个代理,它使用 Apache POI 将笔记文档导出到 excel (xlsm)。 I am following every possible way to release memory by using recycle() or setting up objects to null.However, JVM still goes out of heap size and throws "Out of memory" error.我正在通过使用 recycle() 或将对象设置为 null 来遵循各种可能的方法来释放内存。但是,JVM 仍然超出堆大小并抛出“内存不足”错误。 Here are some more info,这里有更多信息,

  • Default heapsize=256MB默认堆大小=256MB
  • POI version - 3.17 POI 版本 - 3.17
  • How frequent error comes?错误发生的频率如何? If I run the agent from the web 5-6 times continuously.如果我从网络上连续运行代理 5-6 次。
  • xlsm template size : 90 kb xlsm 模板大小:90 kb
  • Number of records writing - 10-30写入记录数 - 10-30

Another thing I am observing but unable to understand is how JVM using/releasing memory.我正在观察但无法理解的另一件事是 JVM 如何使用/释放内存。 For example, I am printing "available" memory before the code starts and after the code ends using following code,例如,我在代码开始之前和代码结束之后使用以下代码打印“可用”内存,

Runtime runtime = Runtime.getRuntime();
double usedMemory = usedMemory(runtime);

System.out.println("START - Initial memory :: " + String.valueOf(usedMemory) )

static double usedMemory(Runtime runtime) {
        long totalMemory = runtime.totalMemory();
        long freeMemory = runtime.freeMemory();
        double usedMemory = (double)(totalMemory - freeMemory) / (double)(1024 * 1024);
        return usedMemory;
    }

When I test my agent very first time it' prints like,当我第一次测试我的代理时,它的打印结果是,

JVM START : Initial memory available : 60 MB JVM 开始:可用初始内存:60 MB

JVM END : Used memory : 90 MB JVM 结束:已用内存:90 MB

Second time when agent starts it prints,第二次代理启动时打印,

JVM START : Initial memory available : 130 MB JVM 开始:可用初始内存:130 MB

JVM END : Used memory : 160 MB JVM 结束:已用内存:160 MB

Even though I am releasing memory at the end of the code, I see it doesn't goes down to initial memory ( 60 MB ) ?即使我在代码末尾释放内存,我也看到它没有降到初始内存(60 MB)?

        /* Free up memory */
        webDoc.recycle();
        docA.recycle();
        vwLookup.recycle();
        curDb.recycle(); 
        session.recycle(); 

        agentContext=null;

        fpath.delete();
        xlFile.delete();

        runtime = Runtime.getRuntime();
        usedMemory = usedMemory(runtime);

        System.out.println("END - MAIN :: Total used memory: " + String.valueOf(usedMemory) );

        freeMemory();

I've opened a PMR regarding this issue last year.我去年就这个问题开设了一个 PMR。 The answer of IBM was as follows: IBM 的回答如下:

I would like to inform you that this is a know limitation with attached jar files to the agent or script libraries.我想通知您,这是一个已知的限制,将 jar 文件附加到代理或脚本库。 See below some of the SPRs reporting the issue:请参阅以下报告该问题的一些 SPR:

SPR # BHUY8VML6R: "Customer Is Experiencing Ongoing Memory Leak Only When Jar Files Are Attached To The Agent In The Database" SPR # BHUY8VML6R:“仅当 Jar 文件附加到数据库中的代理时,客户才会遇到持续的内存泄漏”

SPR # BHUY8PRMKK: "Java Memory Leak When Using Attached Jar Files To The Agent Or Script Libraries." SPR # BHUY8PRMKK:“当使用附加的 Jar 文件到代理或脚本库时,Java 内存泄漏。”

SPR # JSHN83MMMW: "Memory leak in Java agent with attached JAR file" SPR # JSHN83MMMW:“带有附加 JAR 文件的 Java 代理中的内存泄漏”

The only workaround available is as follows: Remove the JAR file from the project of the Java Agent and place it in the jvm/lib/ext folder or reference it by notes.ini parameter JavaUserClasses."唯一可用的解决方法如下:从 Java 代理的项目中删除 JAR 文件并将其放置在 jvm/lib/ext 文件夹中或通过 notes.ini 参数 JavaUserClasses 引用它。”

I know it's not that what do you want to hear... but theses are the facts.我知道这不是你想听到的……但这些都是事实。 Since then, I use OSGi plugins wherever possible.从那以后,我尽可能地使用 OSGi 插件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM