I’ve been wondering how to estimate the memory taken up by an IData object in the IS JVM, depending on its contents. Here’s what I gathered until now :
An IData is in fact a 2-dimensional array, with each entry corresponding to a field of the document.
Each entry consists in a key-value pair, where the key is necessarily a String object, and the value can be a String, an object of any class, even an IData, or an array of any of the above.
Let’s take a simple example, if I have a document type with the following structure:
and if I have an instance of this document where stringField contains “TestString”, then my guess is that this instance will take up as much RAM as needed to hold :
- the String “TestString”
- the String “stringField”
- the String “documentName” (since the document instance itself is an entry in the pipeline’s global IData)
- the overhead for the IData itself and for each of the String objects mentioned above
After looking up RAM usage of Strings in Java (I used http://www.javamex.com/tutorials/memory/string_memory_usage.shtml), I came up with the following calculations:
“TestString” = 24 (String object overhead) + 32 (char array) = 56 bytes
“stringField” = 24 (String object overhead) + 40 (char array) = 64 bytes
“documentName” = 24 (String object overhead) + 40 (char array) = 64 bytes
I’m not sure about the IData’s overhead, but I suppose it has at least 12 bytes for the array header, so I’ll take a wild guess and say it’s 32 bytes.
That gives a total of 56 + 64 + 64 + 32 = 216 bytes for this instance.
This is of course a rough estimate with simplified reasoning, and it may be completely off.
If anyone has any insight into the subject and is willing to confirm or correct me, or may be even to explain that this is a pointless exercise, please do.