Platforms to show: All Mac Windows Linux Cross-Platform
Back to FileMappingMBS class.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Filemapping and Shared Memory | MBS Util Plugin | 10.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Called by the destructor automatically.
FileMappingMBS.CloseFileMapping
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Filemapping and Shared Memory | MBS Util Plugin | 10.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Called by the destructor automatically.
You close all views, than you close the file mapping and finally the file.
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Filemapping and Shared Memory | MBS Util Plugin | 10.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Use this constructor if you continue with OpenSharedMemory or CreateSharedMemory.
See also:
FileMappingMBS.Constructor(file as folderitem, write as boolean = false)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Filemapping and Shared Memory | MBS Util Plugin | 10.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
On Windows you can pass nil for the file parameter in order to have a file mapping using the swap files for back storage.
If write is true, the file is opened/created for write access.
See also:
FileMappingMBS.CreateSharedMemory(name as string, Size as Int64) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Filemapping and Shared Memory | MBS Util Plugin | 10.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Returns true on success and false on failure. The name must be unique on the whole PC.
On success, you can call MapView to access memory.
isWriteable is set to true as shared memory objects are always read and write.
Fails if the shared memory object does exist. In this case, call OpenSharedMemory.
If your application crashes, on the next run the object will still exist on Mac OS X and Linux, so you need to open or delete & create it.
The Size should be a multiply of the page size (4096).
Sets DeleteSharedMemory to true so the object is deleted by the destructor. Set it to false if you don't want that behavior.
Some examples using this method:
FileMappingMBS.EnlargeFile(Size as Int64)
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Filemapping and Shared Memory | MBS Util Plugin | 10.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
This is for file mappings used as temporary storage with a temporary file. You use the Constructor to create a temporary file. This file is enlarged to the size you need. Next you call OpenFileMapping and MapView. To cleanup, you close all views and the file mapping. Now before you close the file, you should call ShrinkFile. ShrinkFile reduces the file size to zero so the operation system doesn't start flushing the shared memory to the file. You can get this automatically if you set ShrinkFileOnClose to true.
Some examples using this method:
FileMappingMBS.MapView(mem as MemoryBlock, offset as Int64, Size as Integer) as FileMappingViewMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Filemapping and Shared Memory | MBS Util Plugin | 11.3 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Returns nil on any error.
Using invalide offset/size values can lead into a bad mapping.
Here you can pass your own memoryblock for back storage.
Make sure your memory is 4 or 64 KB aligned, depending on platform.
(Windows need 64 KB, Mac only 4 KB)
Changed Size parameter from Int32 to Integer in version 21.0.
Xojo may not handle ptr with offsets > 2 GB as of version 2020r2. This is fixed in 2020r2.1.
See also:
Some examples using this method:
FileMappingMBS.MapView(offset as Int64, Size as Integer) as FileMappingViewMBS
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Filemapping and Shared Memory | MBS Util Plugin | 10.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Returns nil on any error.
Using invalide offset/size values can lead into a bad mapping.
(Windows need 64 KB, Mac only 4 KB)
Changed Size parameter from Int32 to Integer in version 21.0.
Xojo may not handle ptr with offsets > 2 GB as of version 2020r2. This is fixed in 2020r2.1.
See also:
FileMappingMBS.OpenFileMapping(MaxSize as Int64 = 0) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Filemapping and Shared Memory | MBS Util Plugin | 10.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
If MaxSize is zero, the file size is used for creating the mapping.
The Size should be a multiply of the page size (4096).
Returns true on success.
Do not call after using OpenSharedMemory or CreateSharedMemory as they open the file mapping for you.
Some examples using this method:
FileMappingMBS.OpenSharedMemory(name as string) as boolean
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Filemapping and Shared Memory | MBS Util Plugin | 10.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Returns true on success and false on failure.
On success, you can call MapView to access memory.
isWriteable is set to true as shared memory objects are always read and write.
Fails if the shared memory object does not exist. In this case, call CreateSharedMemory.
Some examples using this method:
Type | Topic | Plugin | Version | macOS | Windows | Linux | iOS | Targets |
method | Filemapping and Shared Memory | MBS Util Plugin | 10.5 | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | All |
Useful if you used EnlargeFile before.
The items on this page are in the following plugins: MBS Util Plugin.