1 Answer
1

Objects are stored in the heap. Heap spaced can be managed through the VM's configuration file.

A constructor call is more complicated
than an ordinary subroutine or
function call. It is helpful to
understand the exact steps that the
computer goes through to execute a
constructor call:

First, the computer gets a block of unused memory in the heap, large
enough to hold an object of the
specified type.

It initializes the instance variables of the object. If the
declaration of an instance variable
specifies an initial value, then that
value is computed and stored in the
instance variable. Otherwise, the
default initial value is used.

The actual parameters in the constructor, if any, are evaluated,
and the values are assigned to the
formal parameters of the constructor.

The statements in the body of the constructor, if any, are executed.

A reference to the object is returned as the value of the
constructor call.

The end result of this is that you
have a reference to a newly
constructed object. You can use this
reference to get at the instance
variables in that object or to call
its instance methods.

I once wrote a Cache for xml objects (to call them somehow). A Map with a String key (filename) and a reference to the Object (parsed xml file) sufficed. In addition to that, the cache was a singleton (synchronized). Did the same for caching compiled JasperReports (i got a notable speed bump here, because reports where no longer compiled every single time)

So, I should set a limit on the cache size, I guess, in order no to consume all the server memory... I thought that the session and the application would be serialized to disk, just like php does with the session
–
opensasMay 7 '09 at 4:42

2

session is serialized to disk, if needed. But not always. About the cache, if the Map doesn't get astronomically huge, there are no bigger issues, but limiting it is a good idea, if combined with a suitable replacement policy to use when conflicts appear.
–
TomMay 7 '09 at 4:47

what do you mean with conflicts? I've done a similar thing with classic asp's Application object, and defined dependencies for every cached object, so that if needed I can invalidate (erase) every item that is related to some dependency... I've also set a max age cache, something like an hour... just in case...
–
opensasMay 8 '09 at 4:01