|Filemapping and Shared Memory
|MBS Util Plugin
FilemappingMBS is a clever way to map the content of a file into memory without loading it.
All applications are today loaded via mapping using the virtual memory manager. So your data is inside the file but some memory is used to cache it and you can access it as a memoryblock.
You can use this class in several ways:
1. file mapping read/write: Call the constructor with a file, open the file mapping and map memory in your process to read or write a file.
2. file mapping read/write with temporary files: You can create (multi gigabyte) tempory memory storage to store data too big for your application own address space.
3. a variant of 2 is to pass nil to the constructor on Windows to have the data stored in the swap files.
4. use Constructor without paramaters and call CreateSharedMemory to create a shared memory object.
5. use Constructor without paramaters and call OpenSharedMemory to access a shared memory object from another process.
For shared memory objects, be careful how you design it. Your shared memory should have a flag for editing, so one app does not edit while another app edits. Add a version value to check your application versions. Also add a value for the revision of the content so your apps can see modifications. Finally your app should handle the possibility that the application crashes while writing data. So the data can be in a bad state.
- 9 properties
- 11 methods
- method CloseFile
- method CloseFileMapping
- method Constructor
- method Constructor(file as folderitem, write as boolean = false)
- method CreateSharedMemory(name as string, Size as Int64) as boolean
- method EnlargeFile(Size as Int64)
- method MapView(mem as MemoryBlock, offset as Int64, Size as Integer) as FileMappingViewMBS
- method MapView(offset as Int64, Size as Integer) as FileMappingViewMBS
- method OpenFileMapping(MaxSize as Int64 = 0) as boolean
- method OpenSharedMemory(name as string) as boolean
- method ShrinkFile
- 4 shared methods
This class has no sub classes.
Some properties using for this class:
- FileMappingViewMBS.Parent as FileMappingMBS
Some examples using this class:
- /Util/Filemapping/Filemapping Example
- /Util/Filemapping/Huge Temp Storage
- /Util/Filemapping/Shared Memory Client
- /Util/Filemapping/Shared Memory Server
- /Util/Shared Memory
- MonkeyBread Software Releases the MBS Xojo Plugins in version 21.0
- Xojo 2020r2.1 arrived
- MBS Xojo Plugins, version 20.6pr2
- New in the MBS Xojo Plugins Version 20.2
- MonkeyBread Software Releases the MBS Xojo Plugins in version 20.2
- MBS Xojo Plugins, version 18.3pr5
- MBS Real Studio Plugins, version 13.1pr15
- MBS Real Studio Plugins, version 11.3pr14
- MBS REALbasic Plugins, version 10.5pr4
Xojo Developer Magazine
- Version 21.0
- Improved FileMappingMBS class to do >2 GB big shared memory views on 64-bit systems.
- Version 18.3
- Added shared memory methods to FileMappingMBS class.
The items on this page are in the following plugins: MBS Util Plugin.