# Reading/writing unallocated GPU memory

**URL:** <https://forums.developer.nvidia.com/t/reading-writing-unallocated-gpu-memory/13790>\
**Category:** CUDA Programming and Performance\
**Created:** [December 14, 2009, 8:02pm UTC](https://forums.developer.nvidia.com/t/reading-writing-unallocated-gpu-memory/13790 "2009-12-14T20:02:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Julek](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Julek](https://forums.developer.nvidia.com/u/Julek)\
**Post date:** [December 14, 2009, 8:02pm UTC](https://forums.developer.nvidia.com/t/reading-writing-unallocated-gpu-memory/13790/1 "2009-12-14T20:02:16Z")

</div>

I have a program in Visual Studio.  
I allocate some memory pointers on GPU and then read/write them. The problem is, when I set a large number of data, Emulation works differently than on a GPU.  
When I change the program, that it always allocates 5 times more memory on a GPU, the program working on a GPU works well.

So I guess that I am reading/writing from unallocated space.  
The emulation mode doesn’t crash, so I guess that GPU emulator always allocates some more memory than it is set in cudaMalloc.

Is there an easy way to see when I am reading/writing to/from unallocated GPU memory in a kernel?

---

<div class="post-metadata">

**Author:** ![tmurray](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@tmurray](https://forums.developer.nvidia.com/u/tmurray)\
**Post date:** [December 14, 2009, 10:28pm UTC](https://forums.developer.nvidia.com/t/reading-writing-unallocated-gpu-memory/13790/2 "2009-12-14T22:28:00Z")

</div>

cuda-memcheck was added in 3.0b just for this.

---

<div class="post-metadata">

**Author:** ![Julek](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@Julek](https://forums.developer.nvidia.com/u/Julek)\
**Post date:** [December 15, 2009, 12:34am UTC](https://forums.developer.nvidia.com/t/reading-writing-unallocated-gpu-memory/13790/3 "2009-12-15T00:34:02Z")

</div>

> [@](#):
>
> cuda-memcheck was added in 3.0b just for this.

Resolved the problem :) I thought that I am reading/writing from/to unallocated memory because errors are non-deterministic, and did not occur when I allocated more memory - only by accident.

The real problem was - not synchronizing threads after copying global memory to shared memory :P

But thanks for the advice - maybe this tool will help me in the future.
