Issue #578: Large query parameter - out of memory

Type: Bug ReoprtPriority: NormalStatus: FixedReplies: 1
#1

I have an entity object composed of an id, large data in the form of a string and the hashcode of the string as an index. The attached test saves 2000 of these objects, writing the data to a txt file as it goes. It then loops through the data from the file and queries for the entity id based on the data hashcode and the data itself.

I'm running the test with -Xmx512m - I believe this should be sufficient as I only create/read one item of data at a time and am only querying for the id. After about 300 queries the test throws an out of memory exception so I assume the query data is being held internally. I've tried reducing the query-cache programs setting but this made no difference (I'm not 100% sure if it should anyway...). If you could assist it'd be much appreciated!

The aim behind the test is to create a data cache to prevent the need for large data to be held in memory. The data itself forms part of the query as there are duplicate data entries which I only want to store once in the cache.

#2

Your test demonstrates a failure of ObjectDB in evaluating cached query result size.

Since Java doesn't provide information on heap memory size of data structures - ObjectDB does its own evaluation. Every cached result entry contains query request (key) + query result (value). ObjectDB evaluated only the query response, which is usually expected to be larger. In your test the request is very large (the query parameter arguments) and the response is very small. Therefore, even with a small query result cache - ObjectDB kept many cached result entries with their huge query parameter arguments.

Build 2.3.3_06 fixes this issue. Thank you for this report and for the test program.

ObjectDB Support

Reply