google / google/gson

Memory consumption when storing big amount of JsonObjects

Open
#1,449 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Java
Stars
24.2k
Forks
4.5k
Avg merge
6d 4h
Merged PRs (30d)
12

Description

Hi,

I'm working with gson to store a big amount of data while also indexing some of the fields inside.
When I making a HashMap between the element id to the actual JsonObject eventually I get a huge hash map that consume GB's of RAM.
When i'm converting the JsonObject to the actual Java object and then put it inside the HashMap the consumption is reduced significantly.
Is there something I can do or edit in the code to make it save the strings in a better way ?

I saw that:
"Gson doesn't use String.intern() which can cause unnecessary strain on the garbage collector"

But, I prefer to effect performance but not to harm the RAM usages

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.