4

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.

Sergey Galashyn
  • 6,946
  • 2
  • 19
  • 39
  • Have you tried simply increasing the available heap size in CF Administrator? – Ben Doom Mar 15 '10 at 17:17
  • @Ben, yeah I did it at Resin conf (using Railo), but with currently limited VPS RAM this wont help a lot. I just want to try some code optimization before purchasing more RAM, at least I need to know that I'm not "feeding a beast" :) – Sergey Galashyn Mar 15 '10 at 18:02

2 Answers2

2

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
  • 9,375
  • 8
  • 36
  • 47
1

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.

Artsiom Anisimau
  • 1,139
  • 3
  • 11
  • 26
  • 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. – Sergey Galashyn Mar 15 '10 at 16:37
  • Then just clean them by setting values to null when you are sure they are not useful anymore. – Artsiom Anisimau Mar 15 '10 at 16:52