8

I'm working on a simulator that models very complex interactions between many objects, and I mean millions.

I've used XNA because of the useful things that it lets me do easily, especially with the rendering.

My problem is that I'm running into OutOfMemoryExceptions after only a few seconds of simulation. I quickly realized that my program is only running in 32-bit mode, so I only get a few GBs of my somewhat larger amount of RAM.

How can I run an XNA game in 64-bit mode?

annonymously
  • 4,708
  • 6
  • 33
  • 47
  • 1
    right click project, and go to properties, and there should be a box for it – Sam I am says Reinstate Monica Nov 21 '12 at 02:25
  • Use less resources? Ex: load sounds only when needed, not all at load, etc. – Cole Tobin Nov 21 '12 at 02:54
  • 2
    I agree with @ColeJohnson. I think your best bet is to start fine tuning your code. See where you are instantiating new objects when maybe you could reuse them. Perhaps instead of millions of interactions/objects scale it down to a million. It's your call and we don't know enough about your project to comment, but I would try and put my performance cap on now. For all you know, maybe you just have a small memory leak somewhere. If there's this many calculations going on, there's no way the Garbage Collector will be able to clean it up in time. – TyCobb Nov 21 '12 at 03:05
  • @TyCobb Even if I could get my simulation to use less memory, it would never work with just 2-4 GB. I guess I'll just have to change to something else. – annonymously Nov 21 '12 at 04:05
  • Right clicking on the project doesn't work; the option is missing. – BrainSlugs83 Aug 26 '14 at 06:31
  • FYI, you can drop down "x86" and press edit, and the options are mostly all there (you can add x64 and ia64, but there's no option for "ANY CPU" [like there typically is]), and ... they don't work right. Like clicking x64 creates a copy of x86 *as* x86 (normally it doesn't do that). There's some funky juju going on in there. – BrainSlugs83 Aug 26 '14 at 06:38

2 Answers2

3

XNA used to be 32-bit only. You can try to compile to 64-bit, but then you are going to have issues because there won't be any 64-bit XNA libraries to load up. Everything I have found trying to back this up has been comments reminding viewers to compile as x86.

To compile as x64: Right-Click on your solution and go to Configuration Manager. From there select x64 as your Active Solution platform. You may have to create it and then select all your projects as x64. You could also try building as Any CPU since you are on 64-bit Windows, it should automatically start up in 64-bit mode.

EDIT: I found one of my old VM's that had XNA 4 installed on it. It appears that there is not a way to force it to compile to 64-bit. Even when I try to create a new platform, it will only allow me to select x86.

TyCobb
  • 8,909
  • 1
  • 33
  • 53
  • I don't see any way to make it x64. It won't let me change it to x64. – annonymously Nov 21 '12 at 02:42
  • 1
    @annonymously That's probably a big hint that it still doesn't support x64. Is the Active Solution Platform combo disabled or just doesn't display x64? If it just doesn't have x64 you could try selecing and see if it shows up in the next screen, but I wouldn't be surprised if the XNA project is blocking you from being able to create an x64 profile. – TyCobb Nov 21 '12 at 02:47
  • Yeah, it was a long shot, but this is a real pain. – annonymously Nov 21 '12 at 02:51
  • You might want to look into using MonoGame. I'm not sure whether it provides x64 support out of the box, but it has implementations built on top of OpenGL and SharpDX, so it seems like such a thing should be theoretically possible. – Cole Campbell Nov 21 '12 at 14:37
  • Mostly, I just want to compile to ANY CPU. I get that Managed DirectX imposes some 32-bit limitations, but it's too bad there's way to do the 32-bit only parts out of process, or to make it work some other way, etc. – BrainSlugs83 Aug 26 '14 at 06:33
3

This does not directly answer the question. I've already upvoted TyCobb's answer.

I've run into the same issue in the past.

Have you considered switching to SlimDX? It's a wrapper around DirectX and allows you to develop .Net applications using DirectX. According to the documentation:

SlimDX sports complete support for both 32 and 64 bit targets.

It might not be as user-friendly as XNA, but I think it could be a good option for you.

emartel
  • 7,712
  • 1
  • 30
  • 58
  • +1. Nice alternative and you gave me something to play around with once I find some free time. – TyCobb Nov 21 '12 at 03:17
  • If its a wrapper and not a replacement, then it would still be calling 32 bit functions – Cole Tobin Nov 21 '12 at 03:17
  • 3
    @ColeJohnson it's not a wrapper on top of XNA, it's a wrapper on top of DirectX, therefore it would not "still be calling 32 bit functions" – emartel Nov 21 '12 at 03:20