I have a specific thread that I launch when the CF9 application starts. It manages the queue and takes items from the queue to process them. If there are no items in the queue, they will be sleep(). This thread can live for weeks, process and sleep, etc.
The problem I am facing is that the elements that I take from the queue are stored in the heap (it seems, in the old generation) after I finished with them.
The full garbage collection is done by the JVM about every hour (I can tell it with jConsole), and even when it is done, the elements that I processed are still stored on the heap. I can say this because I make a heap bush jmapand analyze it using the Eclipse plugin to analyze data analysis.
So here is my code, this runs in Application.cfc:
<cfthread action="run" name="myThread">
<cfloop condition="APPLICATION.threadProcessing eq true">
<cfif APPLICATION.myQueue.hasNext()>
<cfset tmpItem = APPLICATION.myQueue.next() />
<cfset tmpItem.process() />
<cfset sleep(2000) />
<cfelse>
<cfset sleep(10000) />
</cfif>
</cfloop>
</cfthread>
Can someone tell me if I am using the wrong area or something else? Is there a way to force clean my temporary objects? I suggested that calling the explicit garbage collection would not work, since it still does not clear.
It only became a problem when we switched from CF8 to CF9.
Any help is appreciated - I really would like to maintain this thread and not run it as a scheduled task or something else.
Thanks, Siaran.