Compiling XNA to 64-bit
Asked Answered
C

2

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?

Coralloid answered 21/11, 2012 at 2:22 Comment(6)
right click project, and go to properties, and there should be a box for itRoxyroy
Use less resources? Ex: load sounds only when needed, not all at load, etc.Roentgen
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.Concatenate
@Concatenate 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.Coralloid
Right clicking on the project doesn't work; the option is missing.Aemia
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.Aemia
C
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.

Concatenate answered 21/11, 2012 at 2:32 Comment(5)
I don't see any way to make it x64. It won't let me change it to x64.Coralloid
@Coralloid 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 <New...> 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.Concatenate
Yeah, it was a long shot, but this is a real pain.Coralloid
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.Ellingson
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.Aemia
G
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.

Godparent answered 21/11, 2012 at 3:13 Comment(3)
If its a wrapper and not a replacement, then it would still be calling 32 bit functionsRoentgen
+1. Nice alternative and you gave me something to play around with once I find some free time.Concatenate
@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"Godparent

© 2022 - 2024 — McMap. All rights reserved.