Campbell Ritchie wrote:Don't know; haven't heard of it.
Please explain more, but it sounds at first hearing like something not consistent with the notion of an automatic heap.
Could be Ted, you are referring to a thread pool or the concept of concurrency?
Or do you mean how to optimize memory in Java? Is a concept that you are taking from another language you are familiar?
Ted Gress wrote:So - somewhat related question. Is there any way to "pool" memory in Java?
In Java, memory is always created by the VM and destroyed by the garbage collector in increments of the amount required to hold the state of some specific object(s). To get memory, you create an object (r-value) and to release memory, you let all the l-values pointing to it go out of scope or set them to null. When there are zero l-values pointing to an r-value, that r-value is eligible for garbage collection, meaning that the memory dedicated to holding its state will be marked as unallocated memory, available to hold some other object's state.
The garbage collector affectionally known as GC will get around to marking it thus as it sees fit and on its own schedule.
You cannot directly access "memory" to "pool" it as such (except see below).
The closest things Java has to this are
1) pre-creating objects of some type before you actually need them and maintaining active references to those objects. (active l-values referencing r-values).
2) defining an Collection or array to hold a certain number of objects of some type. The VM will allocate enough memory for that many objects beofre those Collection items or array cells are ever assigned any r-values.
Exception, sort of. You can command the VM to start with a certain minimal amount of memory dedicated to it and you can also tell it to use some up to maximal amount. These are he VM arguments -Xms and -Xmx respectively.