Feb 19 2011, 07:03 AM
I know this is going to sound very n00bish, but I'm kinda new to using virtual memory on Xbox, or for programming games in general. Since the average Xbox is limited to 64Mb or RAM, I obviously can't allocate buffers that large or load in files larger than that. For instance, the old versions of MAME-X used physical memory to load ROMs and couldn't load large ROMs. Then when they started using virtual memory, they had much more memory to work with.
I understand that virtual memory doesn't work like physical memory, and I already understand how to use VirtualAlloc/Free, but what addresses do you read/write to exactly? On my debug Xbox, it says that I have a total of 2GB of virtual memory to work with, and it hardly gets used (only about 8MB max on average), and I'd like to use it to my advantage so that non-immediately used data won't hog up the physical RAM. So would I just choose any address after the first 64MB in the 4GB address space? If so, do you have to manage the addresses allocated yourself? I noticed that there's no Map/UnmapViewOfFile functions on Xbox, so I thought I'd ask. Thanks.
Feb 24 2011, 12:21 PM
The XBOX kernel has several functions that allow you to interact with virtual memory, like NtAllocateVirtualMemory and NtDeallocateVirtualMemory
Other than keeping track of how many chunks of memory you've allocated (in order to prevent memory leaks) you don't need to keep track of it. The kernel does that for you. Virtual Memory can be accessed just like physical memory. In fact, a game usually only reads/writes into virtual memory. The only reason for a game to write to Physical memory would be some special interaction with the XBOX hardware.
Mar 9 2011, 05:39 AM
I think zlinky means use more than 64MB by paging the additional virtual memory to a file on the disk. The kernel has VM functions and a 4GB address space, but allocating more than 64MB of RAM will crash the application because the VMM function never page to disk like windows does. It just dies when > 64MB is used.StepMania
both have their own implementation of a virtual memory manager which allows paging to disk. There was talk of adding it to XBMC
, but I don't think that ever materialized.
Surreal64 also uses paging, but it's very tailored to the app. I'm not sure how they compare against each other performance wise yet, but would like to know.Virtual Memory Allocation On The Xbox, Problems while allocating ram.Why Does The Emulator Have To Load The Whole Rom?, Still pondering this 64MB thing...A "possible" Solution To Ram Shortages...., ...Possible....The Google
I think there's an SDK project that touches on this also:
\Microsoft Xbox SDK\Samples\Xbox\Misc\CustomMemoryAllocator
Undecided atm :/.