0

For some reason I'm getting a System.OutOfMemoryException when I try to declare a new array of float of size 100000000. It's supposed to take up 381MB and my PC has 8GB (2.5 of which are taken up by Windows and other apps).

float[] kineticTile = new float[dimsize]; //<- exception thrown here (dimsize is 100000000)

Declaring same kind of array in other parts of my application works fine.

Other posts on SO have explanations of the problem but I still cannot see an actual solution to it.

I do image rendering and processing and need the whole image in memory (I copy it from a CUDA card) so cannot cut it into smaller fragments. I thought with 8GB of RAM these mere 380MB should not be a problem

Val
  • 1,548
  • 1
  • 20
  • 36
  • ok, it explains what might be the cause but i don't see an actual solution there – Val Jul 30 '15 at 07:35
  • this could have something to do with float being a primitive type and thus being stored in the stack rather than the heap. See [difference between stack and heap](http://stackoverflow.com/a/80113/937093). Why do you want such a large array? – Steffen Winkler Jul 30 '15 at 07:37
  • I do image rendering and processing and need the whole image in memory (I copy it from a CUDA card). I thought with 8GB of RAM these mere 380MB should not be a problem – Val Jul 30 '15 at 07:39
  • Have a look at Shift Technology's and Trisped's answers in the duplicate thread. You can try building as x64 and see if that works. Otherwise, Trisped had a code example of an alternative way to structure that which may also do the trick. Do either of those work for you? – Calcolat Jul 30 '15 at 07:42
  • OK, switching Platform target to x64 did the trick! Thx! – Val Jul 30 '15 at 07:52

0 Answers0