# CUDA memory allocation problem

**URL:** <https://forums.developer.nvidia.com/t/cuda-memory-allocation-problem/43965>\
**Category:** CUDA Programming and Performance\
**Created:** [July 22, 2016, 8:26am UTC](https://forums.developer.nvidia.com/t/cuda-memory-allocation-problem/43965 "2016-07-22T08:26:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Arefinster](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Arefinster](https://forums.developer.nvidia.com/u/Arefinster)\
**Post date:** [July 22, 2016, 8:26am UTC](https://forums.developer.nvidia.com/t/cuda-memory-allocation-problem/43965/1 "2016-07-22T08:26:36Z")

</div>

Hi there, I am very new to CUDA programming. I ran into this one problem while trying to allocate very large 1D array on my GPU (NVIDIA GeForce GTX 745, 4GB) on CUDA 7.5

main(){  
// Memory allocation for voxel locations  
cudaMalloc( (void \*\*)&loc1Dx, vol3DcolSize_vol3DrowSize_vol3DdepSize_sizeof(double) );  
h\_loc1Dx = (double_)malloc(vol3DcolSize_vol3DrowSize_vol3DdepSize_sizeof(double));  
…  
}  
-------------\> Here lets say depsize = 600, colSize = 600, rowSize = 600 elemts  
 **global** void kernel( int vol3DcolSize, int vol3DrowSize, int vol3DdepSize, double_ loc1Dx){  
int depIndex = blockDim.x \* blockIdx.x + threadIdx.x; //dep  
int colIndex = blockDim.y \* blockIdx.y + threadIdx.y; //col  
int rowIndex = blockDim.z \* blockIdx.z + threadIdx.z; //row

```
int index = depIndex + (colIndex + rowIndex*vol3DcolSize)*vol3DdepSize;

if ( (rowIndex < vol3DrowSize) && (colIndex < vol3DcolSize) && (depIndex < vol3DdepSize) ){
	loc1Dx[index] = some calculations.....
            printf("loc1Dx[%d] = %lf\n", index, loc1Dx[index]);
    }
    syncthreads();

```

}

Now, my problem is that if the size of the array is reduced, then the printf works, otherwise, it does not print anything

Can someone please help me figure out what I am doing wrong here?

---

<div class="post-metadata">

**Author:** ![LongY](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@LongY](https://forums.developer.nvidia.com/u/LongY)\
**Post date:** [July 22, 2016, 4:25pm UTC](https://forums.developer.nvidia.com/t/cuda-memory-allocation-problem/43965/2 "2016-07-22T16:25:37Z")

</div>

My guess is that thread access is out of bound, as a result, it causes the printf not working.  
You may try [url][https://developer.nvidia.com/cuda-memcheck[/url]](https://developer.nvidia.com/cuda-memcheck%5B/url%5D) to detect out-of-bound access.
