Hi ,
I have a problem in memory allocation in cuda. when i get memory it gets more than memory i need.
for example when the first pointer get 496 and teh second one get 4096 the first pointer just used 4096bytes but the second one use 65536.
snippet code:
…
mem_size = (4096);//sizeof(float);
cutilSafeCall( cudaMalloc( (void*) &d_idata[i], mem_size));
used_mem =free_mem;
cuMemGetInfo (&free_mem,&total_mem);
used_mem = used_mem-free_mem;
printf(“%d_ free: %u , mem_size: %d , used : %u\n”,i,free_mem, mem_size,used_mem);
i++;
mem_size = (4096);//*sizeof(float);
cutilSafeCall( cudaMalloc( (void**) &d_idata[i], mem_size));
used_mem =free_mem;
cuMemGetInfo (&free_mem,&total_mem);
used_mem = used_mem-free_mem;
printf("%d_ free: %u , mem_size: %d , used : %u\n",i,free_mem, mem_size,used_mem);
…
and the output:
1_ free: 1025608448 , mem_size: 4096 , used : 4096
2_ free: 1025542912 , mem_size: 4096 , used : 65536
could anyone help me please? . Why it gets more than I need these too much memory. I want just 4k but it get 64k. it is terrible.
I have lots of memory allocation and deallocation in my program, and I need memory. but it give me “out of memory” error because after some allocation ,all memory dedicated to those pointers.there aren’t any memory for other pointer as i know I must have memory.
Is there any way to handle it and don’t allow to get these too much memory?
I know i can have a pointer and have just one allocation and handle memory myself by one pointer, but i want to know can cuda handle it itself?
Regards,
Marjan