How can I calculate how much heap memory is needed to serialize a json object which is 5 mb of text?
I am using the fasterxml.jackson library in kotlin if that matters
How can I calculate how much heap memory is needed to serialize a json object which is 5 mb of text?
I am using the fasterxml.jackson library in kotlin if that matters
This question is to broad and mostly depends from data types you chose for properties in POJO
classes. For example, consider you have ten int
properties or ten BigInteger
properties, you can choose for date Calendar
type or long
, and so on. If file size is 5mb
, I assume, it should contain some list of objects inside. In that case, you can create small JSON
file with, for example, 100
objects and measure size in runtime. You can calculate average size for each type of POJO
and multiply it by number of items in JSON
file of given type. And formula could look like below:
Where:
t
- number of different POJO
types.i-th
POJO
object in runtime.i-th
POJO
objects after deserialisation.See: