# cudaMalloc on cufftComplex array returns null

**URL:** <https://forums.developer.nvidia.com/t/cudamalloc-on-cufftcomplex-array-returns-null/3482>\
**Category:** CUDA Programming and Performance\
**Created:** [April 24, 2008, 2:06pm UTC](https://forums.developer.nvidia.com/t/cudamalloc-on-cufftcomplex-array-returns-null/3482 "2008-04-24T14:06:50Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![riclas](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@riclas](https://forums.developer.nvidia.com/u/riclas)\
**Post date:** [April 24, 2008, 2:06pm UTC](https://forums.developer.nvidia.com/t/cudamalloc-on-cufftcomplex-array-returns-null/3482/1 "2008-04-24T14:06:50Z")

</div>

hi.  
i have this bit of code:

cufftComplex \*dst;

```
CUDA_SAFE_CALL(cudaMalloc((void **) &dst,(N_SAMPLES/2+1)* sizeof(cufftComplex)));

```

it is very similar to the examples code in documentation, N\_SAMPLES is defined in a c++ .h file but i have no warnings or errors regarding this.  
pointer dst remains null after this and i can’t figure out why …

i also have:  
cudaMallocHost((void \*_) src,N\_SAMPLES_ sizeof(int));

and this allocates memory perfectly…

thanks.

---

<div class="post-metadata">

**Author:** ![Skribtsov](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Skribtsov](https://forums.developer.nvidia.com/u/Skribtsov)\
**Post date:** [April 25, 2008, 4:21am UTC](https://forums.developer.nvidia.com/t/cudamalloc-on-cufftcomplex-array-returns-null/3482/2 "2008-04-25T04:21:18Z")

</div>

check

- cuda error state.
- out of memory reason
- types of your dst, src variables (one has & sign which means they are of different type or there is a mistype)

---

<div class="post-metadata">

**Author:** ![riclas](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@riclas](https://forums.developer.nvidia.com/u/riclas)\
**Post date:** [April 25, 2008, 10:13am UTC](https://forums.developer.nvidia.com/t/cudamalloc-on-cufftcomplex-array-returns-null/3482/3 "2008-04-25T10:13:30Z")

</div>

thank you very much for answering.

well i have a 8800 GT and i have tried with only one memory block so it is not an out of memory problem…  
as you can see dst is a pointer so it has the & … src is int\*\* so it doesn’t have a & …

care to elaborate on “cuda error state” ?  
i’ll try to debug further on pointer stuff but it’s weird since it is the same line of the examples…

---

<div class="post-metadata">

**Author:** ![MisterAnderson42](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@MisterAnderson42](https://forums.developer.nvidia.com/u/MisterAnderson42)\
**Post date:** [April 25, 2008, 12:25pm UTC](https://forums.developer.nvidia.com/t/cudamalloc-on-cufftcomplex-array-returns-null/3482/4 "2008-04-25T12:25:34Z")

</div>

You have it wrapped in a CUDA\_SAFE\_CALL, which is good. Now compile it in debug mode and run it. CUDA\_SAFE\_CALL should write out the reason for the error.

---

<div class="post-metadata">

**Author:** ![riclas](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@riclas](https://forums.developer.nvidia.com/u/riclas)\
**Post date:** [April 28, 2008, 2:00pm UTC](https://forums.developer.nvidia.com/t/cudamalloc-on-cufftcomplex-array-returns-null/3482/5 "2008-04-28T14:00:56Z")

</div>

problem is debug window has no error … the array just stays empty …

if i do:  
cufftComplex dst[N\_SAMPLES/2+1];

the array is good. i don’t get it why it doesn’t work with malloc …
