ColdFusion 9 - My thread keeps in mind - how can I stop it?

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:

<!--- Kick off a new thread and run through the queue --->
<cfthread action="run" name="myThread">

    <cfloop condition="APPLICATION.threadProcessing eq true">

        <cfif APPLICATION.myQueue.hasNext()>

            <!--- Get next item --->
            <cfset tmpItem = APPLICATION.myQueue.next() />

            <!--- Ask item to process itself --->
            <cfset tmpItem.process() />

            <!--- PROBLEM: these 'tmpItem' objects are never cleaned up by the garbage collector! ---> 

            <!--- Then we sleep for an interval - this is to stop us hogging server resources --->
            <cfset sleep(2000) />


        <cfelse>

            <!--- Nothing in the queue, so sleep for a while... --->
            <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.

+1
4

, . , .

, , , . , . CF6.1, , , .

, , . ( , - 1 , IIRC), , , . , sleep() . , , , , ( ).

, , . ?

+2

, , gc, hprof HAT, , , gc'd.

gc, , , , Object.finalize(). , , , .

0

, , , " ". , . - , .

0

You might want to explore the possibility of blocking the use of the application area.

-2
source

Source: https://habr.com/ru/post/1784877/


All Articles