Allocating Large MemoryBlocks in Virtual Memory

As far as I understand, xojo uses physical memory for their MemoryBlocks, but is it possible to use the Virtual Memory for this?

The problem is that I need to process gigs of data from an incoming stream that goes directly into the memory.
Especially on slower systems the processing runs far behind the incoming stream so I need to cache it.

For now I put all the incoming data into a MemoryBlock and use it by fragments, but this might result in an out of memory situation and for that reason I prefer to allocate space for the MemoryBlock in virtual memory instead of the the physical memory.

I used to do this with Xcode, but is this possible with Xojo?

Oh, other suggestions are welcome too :slight_smile:

Xojo uses whatever memory the process has access to up to the limits of the process
Since its a 32 bit process this limits it to a MAX of 4GB but you may encounter lower limits on some OSes because of how they manage processes
It sounds like what you want is space that is NOT part of your process

[quote=35493:@Norman Palardy]
It sounds like what you want is space that is NOT part of your process[/quote]

You are talking about physical memory, but as I wrote, it does has its limitations.
That’s why my question was how about allocating MemoryBlocks in Virtual Memory, like vm_allocate in other programming languages.

vm_allocate also allocates memory in the same 4 GB block your app has.
It’s just the low level allocator.

If you need to use memory outside your process’s 4 GB, you can use classes like the FileMappingMBS class in our plugin.
Some users use it to access more than 10 GB of memory for storing stuff.

A few ideas, but I am no expert so I may be wrong in what I propose.

If you are running you application on a 64bit machine with more than 4GB of RAM (physical or virtual), you can try to use more memory than the 32bit nature of the Xojo applications dictates using declares. On Windows, maybe VirtualAllocEx could be used for that:

A second idea that occurred to me if your machine has more than 4GB or RAM is that you could use helper applications (console applications launched by the main application), that will allocate a larger amount of total memory to your processing, and you can additionally take advantage of using more than one core for your processing.

My third thought is that if you want to use virtual memory, and I understand you want to use space on your hand disk as memory, then why not simply saving the data to temporary files. It’s probably slower, but it will be much easier.


I am doing it differently now, but thanks for the answers.