Require some insight regarding Objects

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Require some insight regarding Objects

Prakhar Makhija


{"subCategory":"European","bornLocation":"Pondicherry","name":"Goldi Heathers","someSocialStatus":"Active","prefferedCategory":"Within City","dateOfBeingBorn":"16/11/1987","interestedActivity":"Business","personalEarnings":500000.0,"matchfulDesiredEarnings":1000000.0,"identificationNumber":"X582TQ0170TF47002UTD087X74","prefferedClass":"Private","addressState":"Andaman and Nicobar Islands","someAddress":"House Number 143, Near Pie Beach, Port Blair, Andaman and Nicobar Islands, India - 744101","interestedActivityCode":72681.0,"emailId":"[hidden email]"}

*class definition*

public class MyClass {
private String identificationNumber;

private String name;
private String someAddress;
private String addressState;
private String bornLocation;

private String someSocialStatus;
private String prefferedClass;
private String prefferedCategory;
private String subCategory;

private String dateOfBeingBorn;

private String interestedActivity;
private Double interestedActivityCode;

private Double personalEarnings;
private Double matchfulDesiredEarnings;

private String emailId;
// getters & setters
// constructors

*code block*

import com.fasterxml.jackson.databind.ObjectMapper;

ObjectMapper objectMapper = new ObjectMapper();
MyClass myClassObj = objectMapper.readValue(currentLine.getBytes(), MyClass.class);


Likewise having 1.5 million json files
Total size which they are occupying on disk is 940 Mega Bytes

My first doubt is when I load all these json, to make objects out of them, will they occupy the same space in the memory?

My second doubt is about what is going on internally in the JVM's memory, when I am making 1.5 million objects of MyClass.
Lets pick one identifier 'identificationNumber', it has 20 characters.
So just this field 'identificationNumber' is going to occupy 40 bytes only, or (40 * 1,500,000) = 60,000,000 bytes = 57.22 MB

PS : I am not aware which mailing list should be concerned with this kind of query, could you direct me to them, if you are not aware of what I am asking.