1
votes

Here is the use case: we need to limit the amount of RAM use to N Mb and the objects memory consumption is much higher (let's say 10N Mb). We should be able to find a String value for the String key (map) as simple example.

So we'd prefer to respect our memory constraint and loose in performance and we assume some advanced caching strategy should be used.

Does Object support some advanced caching? Can we explicitly set the limit of RAM used and still work?

PS. As some alternatives we consider using more compact data structures (trie for example) taking into account we know the nature of our data.

1

1 Answers

0
votes

A nice thing about ObjectBox is that it does not do caching - it delegates that to the operating system. The OS usually knows very well how to optimize memory among processes according to their usage patterns.

The underlying technology is called memory mapping (e.g. mmap on Linux). Simplified, it makes data on disk available in RAM and thus serves as an excellent cache. The management is completely up to the OS, which you could consider as an "advanced cache" to come back to your question. In short, it automatically uses more memory if available. And it can operate using very little memory. Thus, there is no need to limit the cache.

Adding to this is the fact that ObjectBox itself consumes very little resources (CPU & RAM), and thus leaves more RAM for caching compared to traditional databases.

Regarding tries: if you are heavily relying on string storage/look up, this is a valid alternative if space used on disk is a concern. As always, it depends on your use case.