# cudaMalloc problem

**URL:** <https://forums.developer.nvidia.com/t/cudamalloc-problem/11575>\
**Category:** CUDA Programming and Performance\
**Created:** [August 13, 2009, 5:58pm UTC](https://forums.developer.nvidia.com/t/cudamalloc-problem/11575 "2009-08-13T17:58:19Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![randal](https://developer.download.nvidia.com/images/forums/profile-default-devtalk-84.png) [@randal](https://forums.developer.nvidia.com/u/randal)\
**Post date:** [August 13, 2009, 5:58pm UTC](https://forums.developer.nvidia.com/t/cudamalloc-problem/11575/1 "2009-08-13T17:58:19Z")

</div>

Hi , I see a wierd problem here. I am allocating memory , doing some operations and freeing the memory. but when i build the solution again, as soon as i allocate the memory , the previous values are seen. I use VS05 as my environment

For ex,

Allocating memory A…

once the kernel is run , A has an array say 1 to 10

free memory A…

rebuild the solution…

As soon as A is allocated, i see 1 to 10 in it…

isn this wierd??? and ha, this is happening to only one of the pointers , other pointers are behaving in a nomal way. What could be the reason???

– Randal

---

<div class="post-metadata">

**Author:** ![JeremiahPalmer](https://sea2.discourse-cdn.com/nvidia/user_avatar/forums.developer.nvidia.com/jeremiahpalmer/32/468962_2.png) [@JeremiahPalmer](https://forums.developer.nvidia.com/u/JeremiahPalmer)\
**Post date:** [August 13, 2009, 6:04pm UTC](https://forums.developer.nvidia.com/t/cudamalloc-problem/11575/2 "2009-08-13T18:04:02Z")

</div>

> [@](#):
>
> Hi , I see a wierd problem here. I am allocating memory , doing some operations and freeing the memory. but when i build the solution again, as soon as i allocate the memory , the previous values are seen. I use VS05 as my environment
> 
> For ex,
> 
> Allocating memory A…
> 
> once the kernel is run , A has an array say 1 to 10
> 
> free memory A…
> 
> rebuild the solution…
> 
> As soon as A is allocated, i see 1 to 10 in it…
> 
> isn this wierd??? and ha, this is happening to only one of the pointers , other pointers are behaving in a nomal way. What could be the reason???
> 
> – Randal

It’s not weird at all. That particular array is being reallocated to the same space as before. This is why you should always initialize your arrays after allocation.
