I have build a Berkeley DB in memory to store records. I want to get the ram that used by OS to store it. I used to think that page_size * total_pages (gained by db->stat_print() would help). However, as there is no limit for the length of record value so there are many overflows pages in db. Seems page_size * total_pages can not get the correct answer. So How could I calculate the ram cost? Thank you.
Asked
Active
Viewed 70 times
4
-
I am not sure what "RAM cost" would be with virtual memory. The DB can be as large as addressable memory and the OS/Memory manager swaps pages in and out as needed. – Paul Ogilvie Oct 05 '18 at 08:02
-
Could you give us a little more context? Why do you want to know how much memory it takes? Are you running on an embedded device with limited memory (and no virtual memory)? Or are you planning on storing a _lot_ of data in it? Otherwise my answer's going to be "it doesn't _matter_; memory's effectively free in most situations". – Roger Lipscombe Oct 05 '18 at 08:35
-
Failing that, the answer is "measure it". That is: fill the DB with data that's similar to the real stuff and look at the stats. – Roger Lipscombe Oct 05 '18 at 08:37