Arena storage pool: Difference between revisions

New post.
m (→‎{{header|Wren}}: Changed to Wren S/H)
(New post.)
 
Line 786:
 
That said, using J's built-in support for integers (and for using them) usually results in better code.
 
=={{header|Java}}==
The Java programmer does not generally need to be concerned about memory management as the
Java Virtual Machine (JVM) automatically takes care of memory allocation for new objects,
and the releasing of that memory when an object is no longer needed. The latter operation
is accomplished by a garbage collector which runs in the background at intervals determined
by the JVM. The programmer can force a garbage collection by invoking the System.gc() method,
although this is not restricted to a single specified object.
The programmer can simulate an arena storage pool by using an array or one of the built-in
classes such as List, Map or Set. A simple example is given below.
<syntaxhighlight lang="java">
 
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.List;
 
public final class ArenaStoragePool {
 
public static void main(String[] args) {
List<Object> storagePool = new ArrayList<Object>();
storagePool.addLast(42);
storagePool.addLast("Hello World");
storagePool.addFirst(BigInteger.ZERO);
System.out.println(storagePool);
storagePool = null;
System.gc();
}
 
}
</syntaxhighlight>
{{ out }}
<pre>
[0, 42, Hello World]
</pre>
 
=={{header|Julia}}==
908

edits