Increase the size of a memory mapped file

Posted by sandun dhammika on Programmers See other posts from Programmers or by sandun dhammika
Published on 2012-12-09T12:27:53Z Indexed on 2012/12/09 23:42 UTC
Read the original article Hit count: 320

Filed under:
|
|

I am maintaning a memory mapped file to store my tree like datastructure.

When I'm updating the datastructure ,I got this problem. The file is limited on it's size and can't be too long or too small.

I have a methods like

 void mapfile_insert_record(RECORD* /* record*/);

 void mapfile_modify_record(RECORD* /* record*/);

Both operations could lead to exceed the space which is free on memory file.

How do I overcome this? What strategy I should use.

  1. calculate whether it requires to exceed the file as a pre-condition on both methods.
  2. Dynamically exceed it , for a example manage a timer and constantly polling file for it's free avaliable size and then automatically extend it.

Any ideas or patterns to overcome this problem?

© Programmers or respective owner

Related posts about c++

Related posts about memory