eclipse-store / store

High-Performance Java-Native-Persistence. Store and load any Java Object Graph or Subgraphs partially, Relieved of Heavy-weight JPA. Microsecond Response Time. Ultra-High Throughput. Minimum of Latencies. Create Ultra-Fast In-Memory Database Applications & Microservices.
https://eclipsestore.io/
Eclipse Public License 2.0
166 stars 14 forks source link

About the issue of storage occupying memory #226

Open lxqaoliao opened 1 month ago

lxqaoliao commented 1 month ago

May I ask if starting Embedded Storage Manager without shutting it down and with hundreds of thousands of data, would it consume a lot of memory?

hg-ms commented 1 month ago

Yes, it will require quite a lot of memory by design. The basic idea of EclipseStore is to keep data in memory to maximize access speed during runtime. When the storage manager is started it will load all persisted data into memory recreate the whole persisted object graph except lazy loaded parts.

An empty EclipseStore instance requires just some few MB memory. The more important part are the management data required for each persisted object instance. To estimate the memory usage you can calculate round about 188 Bytes per stored Object. LazyReferences require additional 104 Bytes even if unloaded. Using them with very small objects may counterproductive. Microstream also uses an internal off-heap cache that can become quite large. If the default configuration of that cache is not suitable have look here. And, last but not least, your java objects also require memory.

lxqaoliao commented 1 month ago

Can I shut down to free up memory after use?

lxqaoliao commented 1 month ago

Or is there a way to directly release all registered instances?

Bios-Marcel commented 11 hours ago

You can use Lazy Loading and Lazy Collections. This will load and unload data as required.

However, if you use this in an uncareful way, it could get rather slow due to a lot of loading and unloading of data.