I have a memory mapped file, and a page in a view which is currently committed. I would like to decommit it. MapViewOfFile tells me I cannot use VirtualFree on file mapped pages. Is there some other way to do it?
How can I decommit a file-mapped page?
1k Views Asked by Suma At
1
There are 1 best solutions below
Related Questions in WINAPI
- Make screenshot of DirectX window that is hidden and doesn't have focus
- Is it valid to mutilayered a critical section?
- Implementing callback function for dialog-based application
- Where is the 'EnablePinning' property in the ribbon framework's recent items?
- Confusion about CTRL_SHUTDOWN_EVENT handling in DLLs and WM_QUERYENDSESSION
- Standard control transparency. Possible?
- Disable all power options from the Start menu
- call Win32 API in flex to set Window Display Affinity
- heap error after changing from new allocation to smartpointer
- Win API - Delete all files except some
- Finding the default application for a particular file name extension (Even when served by a metro app)
- How do I declare OutputDebugStringA without windows.h macros?
- WPF giving maximize,minimize,resize control to child window
- Can a dialog intercept drag'n'drop messages passed to its controls?
- WinApi and work with several domains
Related Questions in MEMORY-MANAGEMENT
- Calling Dealloc method in sprite kit
- Allocating memory for pointers inside structures in functions
- Beginner iOS memory management
- Deleting a dynamically allocated 2D array
- DataTable does not release memory
- how to resize image properly without memory warning
- Application Verifier limits Heap Allocations by default?
- C++ assign const reference to instance variable (memory issues?)
- What memory issues may arise from a single page JavaScript/AJAX application when kept open over a period of months?
- How to increase PHP memory_limit in Debian Jessie?
- Is this correct point to free char*
- Using parse.com and having allocation memory issue
- Qt object ownership when using lambda as slot
- Any ideas why one object is not deallocated in objective-c ARC
- How do I set a buffer in a possibly recursive procedure?
Related Questions in FILE-MAPPING
- Writing windows debugger, Read/WriteProcessMemory vs file mapping
- C++ MapVirtualFileEx - Creating multiple maps for faster access
- I cannot memory map large files. Map Failed. OutOfMemoryError
- Filemap readding issues
- Access denied on CreateFileMapping when run under different user accounts with runas
- What part of the RAM is used by the system file cache in Windows?
- Copy Memory Block
- problems with .Net File Mapping
- error when access data from boost mapped_region
- PIMAGE_NT_HEADERS Showing different Values
- How to load (or map) file part maximum size, but fit in RAM on Windows?
- CreateFileMapping size limit in a 64-bit process
- How to send a bitmap and text data thought processes using file mapping?
- match 2 strings exactly except at places where there is a particular string in python
- Bus error after mmap success
Trending Questions
- UIImageView Frame Doesn't Reflect Constraints
- Is it possible to use adb commands to click on a view by finding its ID?
- How to create a new web character symbol recognizable by html/javascript?
- Why isn't my CSS3 animation smooth in Google Chrome (but very smooth on other browsers)?
- Heap Gives Page Fault
- Connect ffmpeg to Visual Studio 2008
- Both Object- and ValueAnimator jumps when Duration is set above API LvL 24
- How to avoid default initialization of objects in std::vector?
- second argument of the command line arguments in a format other than char** argv or char* argv[]
- How to improve efficiency of algorithm which generates next lexicographic permutation?
- Navigating to the another actvity app getting crash in android
- How to read the particular message format in android and store in sqlite database?
- Resetting inventory status after order is cancelled
- Efficiently compute powers of X in SSE/AVX
- Insert into an external database using ajax and php : POST 500 (Internal Server Error)
Popular Questions
- How do I undo the most recent local commits in Git?
- How can I remove a specific item from an array in JavaScript?
- How do I delete a Git branch locally and remotely?
- Find all files containing a specific text (string) on Linux?
- How do I revert a Git repository to a previous commit?
- How do I create an HTML button that acts like a link?
- How do I check out a remote Git branch?
- How do I force "git pull" to overwrite local files?
- How do I list all files of a directory?
- How to check whether a string contains a substring in JavaScript?
- How do I redirect to another webpage?
- How can I iterate over rows in a Pandas DataFrame?
- How do I convert a String to an int in Java?
- Does Python have a string 'contains' substring method?
- How do I check if a string contains a specific word?
You cannot decommit it, but what you really want is not decommitting it ...
What you really want is to release the page from a memory. This can be done by using VirtualUnlock. See VirtualUnlock Remarks:
Note: As documented, the function will return FALSE (the page was not locked) and GetLastError will return ERROR_NOT_LOCKED.
This is described in Guillermo Prandi's question CreateFileMapping, MapViewOfFile, how to avoid holding up the system memory.
Remarks: I think you can view it this way: decommitting a mapped page is nonsense - pages is commited whenever it is backed by a physical storage, be it a memory or a file. File mapped page cannot be decommitted in this sense, as it will be always backed by the file.
However, the code in the question mentioned is measuring the memory footprint, but what it measures is not representative, as the fact the page is removed from the process working set does not necessarily mean it is no longer present in a memory.
I have performed a different experiment, measuring how long it takes to read a byte from a memory mapped page. After unlocking the page or unmapping the view and closing the mapping handle the access was still fast.
For the access to be slow (i.e. to really discard the page from the memory) it was necessary to unmap the view and close BOTH memory mapping handle and file handle (the last was surprising to me, as I expected unmapping the view and closing the mapping handle will be enough).
It is still possible system will take VirtualUnlocked as a hint and it will discard the pages sooner, once it needs to discard something, but this is something I have to think about yet how to prove.