Friday, February 24, 2006

Difference between free and delete

I stumbled across the following article on www.voidnish.com. It compares the differences between using the new / delete pair and the malloc / free pair. The 'Tip for scalar and vector new/delete' in the article helped me realize why my one DLL had a memory leak when handling char arrays.

Obviously a seasoned C++ programmer would know this, but me being a C# / Java programmer and only a C++ programmer when the situation calls for it, I did not realize that mixing the two ways of allocating memory and freeing them again will have such an effect.

Just another reason I love my C# / Java managed code world ;)

No comments: