Java Excel POI stops after multiple execution by quartz

后端 未结 1 516
Happy的楠姐
Happy的楠姐 2021-01-13 04:50

I\'d like to have a couple of insights on this.

I have a program that reads and writes from a database to an excel file. It\'s execution is based on a timer using Qu

1条回答
  •  长发绾君心
    2021-01-13 05:00

    After a lot of cursing, praying and searching I think I have found a possible solution to this. What I did was add System.gc(); at the end of my Quartz job class. Thus, calling the garbage collection everytime the program finishes the job. It's only a possible solution and not a concrete answer because I'm still eating up a lot of heap memory (I believe there's still some memory leak somewhere in the chaos of my code). But, with the System.gc(); I'm consuming considerably less. I'm just not sure how this happens. Logically I would think that GC will only effect the memory allocation and not memory performance of the program. See image below; the top graph is the one with GC while the bottom is the one without.

    enter image description here

    As you can see the one with the GC is consuming less heap memory than the one without. I assume that the memory usage will still be the same with the GC, but once the GC is called the used heap space will decline. I'll be using this solution for now until a better answer appears.

    0 讨论(0)
提交回复
热议问题