Jump to content


Photo

Using Virtual Memory On Xbox


  • Please log in to reply
2 replies to this topic

#1 _zlinky

_zlinky

    X-S Member

  • Members
  • Pip
  • 75 posts

Posted 19 February 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.

#2 halofreak1990

halofreak1990

    X-S Young Member

  • Members
  • Pip
  • 57 posts
  • Location:The Netherlands
  • Xbox Version:v1.6
  • 360 version:v1 (xenon)

Posted 24 February 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.

#3 Ez0n3

Ez0n3

    X-S Member

  • Dev/Contributor
  • Pip
  • 74 posts
  • Xbox Version:unk
  • 360 version:unknown

Posted 09 March 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 and MAMEoX 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 wink.gif

I think there's an SDK project that touches on this also:
\Microsoft Xbox SDK\Samples\Xbox\Misc\CustomMemoryAllocator

Undecided atm :/.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users