Platforms to show: All Mac Windows Linux Cross-Platform
FileMappingMBS class
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
class | Filemapping and Shared Memory | MBS Util Plugin | 10.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
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
- property DeleteFileOnClose as Boolean
- property DeleteSharedMemory as Boolean
- property File as FolderItem
- property isWriteable as Boolean
- property Lasterror as Integer
- property LasterrorString as String
- property Name as String
- property SharedMemorySize as Int64
- property ShrinkFileOnClose as Boolean
- 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
- shared method DeleteSharedMemory(name as string) as boolean
- shared method GetSharedMemoryValue(name as string) as MemoryBlock
- shared method HasSharedMemoryValue(name as string) as Boolean
- shared method SetSharedMemoryValue(name as string, data as MemoryBlock) as Boolean
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
Blog Entries
- 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
Release notes
- 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.
FileListMBS - FileMappingViewMBS