views:

78

answers:

2

Hello.

I have a CFC as singletone object in Application scope.

One of the methods is used for massive data processing and periodically causes the "Java heap space" errors.

EDIT All variables inside the method are VAR-scoped, so they should not be kept in the object scope when invokation ended.

It can be a bit dumb question for Java people, but I'd like to know how Java garbage collector cleans up the CFC methods memory: only when whole request ends, or maybe right after each method/function invokation?

Second option is interesting because it can allow me to split my large method into the few, as one of the possible optimizations.

+1  A: 

Java releases resources after there is no reference to object. You have singleton application scope object which actually mean that it will never release it instance variables and class variables. Except you will do this manually in your code. You should show some code to get more advises how to optimize your code.

Artic
Thanks, you reminded be about one importand thing I forgot to mention: local scope for variables. Though I'm not sure if I can provide some useful code samples here because my core question is about higher level things.
Sergii
Then just clean them by setting values to null when you are sure they are not useful anymore.
Artic
+2  A: 

it's well known that coldfusion will not perform garbage collection until after the current request has been processed even if you try invoking it manually.

rip747
Oh. It's exactly what I was thinking about, fortunately I already have a solution. Thanks!
Sergii