
11Introduction to Java in MATLAB
®
1.1.3 Memory Usage
Java references appear as zero-byte objects in the workspace. Unfortunately, there is no simple
workaround for this:
20
>> whos
Name Size Bytes Class Attributes
ans 1x1 8 double
dim 1x1 java.awt.Dimension
One (imperfect) solution for reporting Java object size in MATLAB is to use utilities such as
Classmexer
21
that rely on JVM Instrumentation (available since JVM 1.5).
22
To use Classmexer,
download its JAR le, add it to the Java classpath (statically or dynamically), and then add the
following line to our java.opts le (see Section 1.9):
-javaagent:classmexer.jar
No