Search code examples
javacachingnetbeansshared-memorydata-persistence

Java - Caching of a large object instance for multiple runs, possibly in NetBeans


i am trying to figure out if there is a 'simple' way to store persistently a large object instance in the JVM memory to be shared and re-used for multiple runs by other programs. I am working on netbeans using java 8. The data is some ~500 MB of serialized objects. They fit easily in the RAM but take few minutes to de-serialize from disk each time.

Currently the program load a serialized object from the local disk into memory for each run. As the data is only read from during the test, it would be optimal to hold it in memory and access it directly at each run.

We've looked into RMI but the overhead, the marshalling process and the transmission will kill the performance. I was wondering if there is a more direct way to access data from a program running on the same JVM, like sharing memory.

The multiple runs are to test different processing / parameters on the same input data.

I am open to suggestion on the best practice to achieve this 'pre-loading', any hints would be very appreciated.

Thanks


Solution

  • If I understood well you need to read a huge amount of data from disk and use this data only for test purpose.

    So every time you run the tests you need to reload them and it slow down your tests.

    If this is the situation you can also try to create a disk on memory (ram disk). So your file is saved on a disk with the performances of the ram.

    Here is a link for the command ramfs to create it on linux systems