Re: memory leak?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



On Sat, 28 Jul 2007 11:02:40 -0000, wanwan <ericwan78@xxxxxxxxx> wrote:

I found a solution that doesn't make too much sense to me.

Originally I used malloc and free in treating the use of memory in the
char pointer like so:
char* ca = (char*) malloc(1234*sizeof(char));

Multiplying by sizeof(char) is pointless, because sizeof(char) == 1 by
definition.

...
free(ca);

.... It caused memory leak.

After playing with my code, I change to using new and delete. The
memory leak is now gone.

I thought they are the same thing. .Anyway, hope someone else can make
use of my findings.

They should be the same thing WRT leak detection (verify by temporarily
deleting the delete), and if that's all that has changed, I can't explain
it. If you had answered the questions I posed at the end of my last
message, I'd have had more to go on.

--
Doug Harrison
Visual C++ MVP
.



Relevant Pages

  • [NT] Services for UNIX 2.0 Suffer from a Remotely Triggered Memory Leak
    ... Services for UNIX 2.0 Suffer from a Remotely Triggered Memory Leak ... 2000 are not affected by the vulnerability. ... * A vulnerability that could enable an attacker to cause the NFS service ...
    (Securiteam)
  • RE: Memory increasing even when in debug-break
    ... there are 2 types of memory leak in .Net: ... More interesting is the debugger breaks while memory still increasing ... Microsoft Online Community Support ...
    (microsoft.public.vsnet.debugging)
  • Re: Memory leak in the Driver
    ... will it also work for device driver ??? ... if the following application is used then, there is no memory leak. ...
    (microsoft.public.windowsce.platbuilder)
  • Re: Memory Leak
    ... Regarding .Net memory leak issue, an important step is determing if it is ... should not use the "Mem Usage" column in task manager which is misleading. ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: Memory Leak
    ... managed leak or unmanaged memory leak. ... should not use the "Mem Usage" column in task manager which is misleading. ... Microsoft Online Community Support ...
    (microsoft.public.dotnet.languages.csharp)