Java objects with small memory footprint #1113
AlexeyPirogov
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
It's excellent that we can create GraphQL classes, but using instances of these classes can be memory-intensive.
In my situation, I'm dealing with Elastic Search objects that have over 4,000 fields. However, most clients only need to load a few fields, making it a perfect use case for GraphQL and Projection generated classes for requests. The problem is that each Java object from response will contain null values for the unused fields.
An alternative solution is to generate classes with identical getters, but with a map that stores the actual response from the GraphQL server. The getters can then retrieve the values from the map, and if a value is not present, return null or throw an exception, depending on the client's preference. This approach can help reduce memory usage by only storing the necessary fields in the object.
Beta Was this translation helpful? Give feedback.
All reactions