# Memory Allocation Behavior

**URL:** <https://forums.developer.nvidia.com/t/memory-allocation-behavior/19670>\
**Category:** CUDA Programming and Performance\
**Created:** [November 10, 2010, 1:35pm UTC](https://forums.developer.nvidia.com/t/memory-allocation-behavior/19670 "2010-11-10T13:35:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fcs](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@fcs](https://forums.developer.nvidia.com/u/fcs)\
**Post date:** [November 10, 2010, 1:35pm UTC](https://forums.developer.nvidia.com/t/memory-allocation-behavior/19670/1 "2010-11-10T13:35:11Z")

</div>

I have a weird behavior in my code.  
I need to allocate very large amount of memory (splitted in many buffers (aroud 20)) and the alloc failed.

- First strange thing: when alloc failed, i am able to see it and to get a wrong return code only on the first kernel (which returns CL\_OUT\_OF\_RESSOURCES) code not at allocation with an (CL\_OUT\_OF\_MEMORY)

- Second strange thing: the amount of allocated memory whiche makes my cde to crash is far under the card’s limitation.  
I test it on a Tesla C1060 with CL\_DRIVER\_VERSION=256.35 / CL\_DEVICE\_GLOBAL\_MEM\_SIZE=4294770688 / CL\_DEVICE\_MAX\_MEM\_ALLOC\_SIZE=1073692672 and everything is fine (i succeed in allocate my 2.6 Go of memory)  
On a GeForce GTX 480 with CL\_DRIVER\_VERSION = 256.44 / CL\_DEVICE\_GLOBAL\_MEM\_SIZE=1610285056 / CL\_DEVICE\_MAX\_MEM\_ALLOC\_SIZE=402571264 , i crash whith a total amount of memory allocated close to the CL\_DEVICE\_MAX\_MEM\_ALLOC\_SIZE’s 400Mo which prevent me to use the 1.2Go leaving on this card…

Has anybody seen such behavior and found a way to get rid of theses problems?

---

<div class="post-metadata">

**Author:** ![fcs](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@fcs](https://forums.developer.nvidia.com/u/fcs)\
**Post date:** [November 10, 2010, 1:35pm UTC](https://forums.developer.nvidia.com/t/memory-allocation-behavior/19670/2 "2010-11-10T13:35:11Z")

</div>

I have a weird behavior in my code.  
I need to allocate very large amount of memory (splitted in many buffers (aroud 20)) and the alloc failed.

- First strange thing: when alloc failed, i am able to see it and to get a wrong return code only on the first kernel (which returns CL\_OUT\_OF\_RESSOURCES) code not at allocation with an (CL\_OUT\_OF\_MEMORY)

- Second strange thing: the amount of allocated memory whiche makes my cde to crash is far under the card’s limitation.  
I test it on a Tesla C1060 with CL\_DRIVER\_VERSION=256.35 / CL\_DEVICE\_GLOBAL\_MEM\_SIZE=4294770688 / CL\_DEVICE\_MAX\_MEM\_ALLOC\_SIZE=1073692672 and everything is fine (i succeed in allocate my 2.6 Go of memory)  
On a GeForce GTX 480 with CL\_DRIVER\_VERSION = 256.44 / CL\_DEVICE\_GLOBAL\_MEM\_SIZE=1610285056 / CL\_DEVICE\_MAX\_MEM\_ALLOC\_SIZE=402571264 , i crash whith a total amount of memory allocated close to the CL\_DEVICE\_MAX\_MEM\_ALLOC\_SIZE’s 400Mo which prevent me to use the 1.2Go leaving on this card…

Has anybody seen such behavior and found a way to get rid of theses problems?
