Allocate much memory error

I have a Geforce 8800 GT with 512 mb ram.

When i try to allocate exactly 386 mb of ram it crashes.

100663296 * 4 Bytes = 402653184 / (1024 * 1024) = 386 mb

When i try to allocate a little less for example 352 mb = 92274304 floats it works.


There recently have been some threads about larger memory allocations (e.g. start with ).

You can try using

long total[] = { 0 };
long free[] = { 0 };
JCuda.cudaMemGetInfo(free, total);
System.out.println("Total "+total[0]+" free "+free[0]);

to see how much memory is still free before allocating, but note (as also pointed out in the other threads) that the maximum size for a single allocation might be smaller than the free memory (e.g. due to memory fragmentation).