问题描述
感谢您的时间。
我们有控制台应用程序,我们在运行时使用分配两个缓冲区malloc API。
在退出应用程序时,我们使用free释放内存。
在运行时分配缓冲区调用免费API后,如果我们尝试访问我们仍然可以访问它的缓冲区。
指针在VS2005调试器中没有显示为坏指针。当我们自由运行时,指针1上的内存被释放,内存窗口显示已分配内存的问号。
如何通过调用免费API来确保释放内存? / p>
前两个图像对应于buffer1。第一个是在调用malloc之前,第二个图像是在gpstrNibpApp-> pu8NibpMsg上调用免费API后捕获的。
如果您有任何建议,请与我们联系.Regards,
GSR
Hi,
Thanks for your time.
We have console application in which we are allocating two buffers at run time using malloc API.
While the exiting the application we are deallocating the memory using free.
After calling the free API on run time allocated buffer, if we try to access the buffer we are still able to access it.
The pointer is not shown as bad pointer in VS2005 debugger. Where as on pointer1 when we run free the memory is freed and the memory window displays question marks for the allocated memory.
How to make sure that the memory is freed by calling free API?
The first two images correspond to buffer1. The first one is before calling malloc and the second image is captured after calling free API on the gpstrNibpApp->pu8NibpMsg.
Please let me know if you have any suggestions.Regards,
GSR
这篇关于关于在运行时释放内存的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!