JamaicaVM -- User Documentation: The Virtual Machine for Real-time and Embedded Systems | ||
---|---|---|
Prev | Chapter 4. Configuration of the Memory Management | Next |
Imagine, we want to determine the worst-case-execution-time of an allocation of a StringBuffer object, as it is done in the Hello.java-example shown above. If this examples was build with dynamic garbage-collection work and a heap size of 292k bytes, we get
max_gc_units = 14
as has been shown above.
If our target platform gives a worst-case-execution-time for one unit of garbage collection work of 1.6μs, we have
wcet_of_gc_unit = 1.6μs
We use the numblocks tool to find the number of blocks required for the allocation of a java.lang.StringBuffer object:
> numblocks java.lang.StringBuffer 1 |
A StringBuffer object requires just a single block of memory, so that
numblocks(S new StringBuffer() ) = 1
and the total worst-case-execution time of the allocation becomes
wcet(S new StringBuffer() ) = 1· 14· 1.6μs = 22.4μs
If we had used static garbage collection work with the same heap size, the amount of garbage collection work on an allocation of one block could have been fixed to 6 units, so that in this case the worst-case-execution-time of the allocation becomes
wcet staticGC (S new StringBuffer() ) = 1· 6· 1.6μs = 9.6μs
After creation of the java.lang.StringBuffer object, a character array of 16 elements is allocated during the execution of StringBuffer's initialisation routine. For this allocation, we can just as well determine the worst-case-execution-time by first determining the number of blocks required:
> numblocks char[16] 2 |
and we get
wcet(S new char[16] ) = 2· 14· 1.6μs = 44.8μs
and
wcet staticGC (S new char[16] ) = 2· 6· 1.6μs = 19.2μs
Here are some typical values for the number of blocks required on an allocation of different objects or arrays:
Table 4-1. Typical number of blocks for objects
Class | numblocks |
---|---|
new java.util.Vector() | 1 |
new boolean[1024] | 5 |
new byte[64] | 3 |
new char[256] | 19 |
new int[1024] | 147 |
new Object[1000000] | 142860 |
The output of numblocks when using option -all can be used to get a quick overview on the number of blocks for all classes used by an application, eg:
> numblocks -all HelloWorld Class: Blocks: java/lang/ThreadGroup 1 java/lang/OutOfMemoryError 1 java/text/ParseException 1 java/util/ConcurrentModificationException 1 java/util/Random 1 java/io/Writer 1 java/util/ArrayEnumeration 1 java/lang/Number 1 java/util/SimpleTimeZone 3 java/lang/UnsatisfiedLinkError 1 java/util/Vector 1 java/util/Date 1 java/lang/BinaryValue 2 java/lang/reflect/Modifier 1 java/util/List 1 java/lang/Runnable 1 java/lang/NoSuchFieldException 1 java/lang/reflect/AccessibleObject 1 java/lang/InstantiationException 1 jamaica/NYIException 1 java/util/AbstractList$SL 1 java/lang/VirtualMachineError 1 java/lang/DecimalValue 1 java/lang/Byte 1 java/lang/reflect/Member 1 java/util/NoSuchElementException 1 java/lang/Character$Subset 1 java/lang/Boolean 1 java/io/OutputStream 1 java/lang/IndexOutOfBoundsException 1 java/lang/Math 1 java/io/SyncFailedException 1 java/lang/Long 1 java/util/Iterator 1 java/lang/StringBuffer 1 java/util/AbstractSet 1 java/io/PrintStream 1 java/lang/Throwable 1 java/lang/reflect/Field 2 java/lang/ref/Reference 2 java/lang/NullPointerException 1 java/lang/RuntimeException 1 java/lang/Short 1 java/util/Dictionary 1 java/util/Collection 1 java/lang/FinalizerThread 2 java/lang/Integer 1 java/lang/System 1 java/lang/IllegalMonitorStateException 1 java/lang/IllegalThreadStateException 1 java/lang/NoClassDefFoundError 1 java/lang/LinkageError 1 java/util/Set 1 java/util/Properties 2 java/util/Locale 1 java/lang/String$1 1 java/lang/NumberFormatException 1 java/io/FileNotFoundException 1 java/text/Format 1 java/lang/Runtime 1 java/lang/ClassNotFoundException 1 java/util/HashtableElement 1 java/util/Comparator 1 java/lang/Float 1 java/lang/Character$UnicodeBlock 1 java/io/PrintWriter 1 java/lang/SecurityException 1 java/io/FileInputStream 1 java/lang/InterruptedException 1 java/util/Calendar 2 java/lang/Error 1 java/lang/NoSuchMethodException 1 java/lang/CloneNotSupportedException 1 java/util/AbstractList 1 java/lang/Exception 1 java/lang/InternalError 1 java/lang/reflect/Method 1 java/util/Hashtable 1 java/lang/ClassCastException 1 java/lang/String 1 java/lang/IllegalStateException 1 java/lang/ArrayStoreException 1 java/lang/ref/JamaicaReferences 1 java/lang/Object 1 java/lang/Void 1 java/util/Map 1 java/lang/IllegalAccessException 1 java/lang/UnsupportedOperationException 1 java/lang/ref/ReferenceQueue 1 java/util/GregorianCalendar 2 java/io/FileOutputStream 1 java/util/Hashtable$1 1 java/util/Hashtable$2 1 java/util/Hashtable$3 1 java/util/Hashtable$4 1 java/util/Hashtable$5 1 java/util/Hashtable$6 1 java/lang/Class 4 java/net/MalformedURLException 1 java/lang/ClassLoader 1 java/io/InterruptedIOException 1 java/io/UnsupportedEncodingException 1 java/util/AbstractList$LI 1 java/util/AbstractList$1 1 java/io/OutputStreamWriter 1 HelloWorld 1 java/lang/ArithmeticException 1 java/util/Enumeration 1 java/io/InputStream 1 java/lang/reflect/InvocationTargetException 1 java/lang/StringIndexOutOfBoundsException 1 java/lang/Comparable 1 java/lang/ArrayIndexOutOfBoundsException 1 java/lang/Character 1 java/lang/ClassFormatError 1 java/lang/IllegalArgumentException 1 java/util/TimeZone 1 java/lang/Thread 2 java/lang/NegativeArraySizeException 1 java/lang/ExceptionInInitializerError 1 java/lang/reflect/Constructor 1 java/io/FilterOutputStream 1 java/io/File 1 java/util/AbstractCollection 1 java/io/Serializable 1 java/util/Map$Entry 1 java/lang/Double 1 java/text/DateFormat 1 java/io/FileDescriptor 1 java/io/IOException 1 java/lang/reflect/Array 1 java/util/ListIterator 1 java/lang/Cloneable 1 |