Article View: comp.sys.mac.programmer.codewarrior
Article #1413[help] Why does this leak?
From: petrock
Date: Mon, 02 Oct 2000 00:00
Date: Mon, 02 Oct 2000 00:00
53 lines
2150 bytes
2150 bytes
Hello,
I am using Codewarrior Pro 5.3, with a newly installed Univ
Interface 3.3.2. Here is the problem. I ran a program that I wrote
through Spotlight. Spotlight said I was leaking. i looked and I'm not.
So I created a test project (C++ console app) to see if it was me or
Spotlight... here is the code
#include <stdio.h>
#include <stdlib.h>
#include "SpotlightAPI.h"
using namespace std; //introduces namespace std
int main()
{
printf("about to allocate memory\n") ;
char * tmp = (char*) malloc(100); // this leaks
free(tmp);
printf("free'd memory\n") ;
return(0) ;
}
Spotlight says that this is leaking. This is the exact code I have in
the test source file. Didn't change a thing... I thought that it might
be that my univ interfaces got screwed up, so I installed a fresh copy,
re-compiled all the headers etc... same problem. If I use "new" instead
of malloc or even calloc, I get the same problem. but if I use NewPtr
the problem goes away... I don't understand this. Does anyone have an
idea? Thanks...
here is the output from Spotlight
Spotlight (1.0) log for: Test.out.xSYM
Mon, Oct 2, 2000 3:17 PM
** Leaked Ptr blocks:
Size: 65536 bytes
Stack trace:
__sys_alloc
link_new_block
allocate_from_var_pools
malloc
main (HelloWorld.cp 20)
--Rob
Sent via Deja.com http://www.deja.com/
Before you buy.
Technical Details
Message-ID:
<8rao64$4u3$1@nnrp1.deja.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10bcce,f4b1d593e54aa750,start X-Google-Attributes: gid10bcce,public X-Google-Thread: f635e,f4b1d593e54aa750,start X-Google-Attributes: gidf635e,public From: petrock <petrock00@my-deja.com> Subject: [help] Why does this leak? Date: 2000/10/02 Message-ID: <8rao64$4u3$1@nnrp1.deja.com> X-Deja-AN: 676742410 X-Http-Proxy: 1.0 x69.deja.com:80 (Squid/1.1.22) for client 128.113.146.62 Organization: Deja.com - Before you buy. X-Article-Creation-Date: Mon Oct 02 19:37:41 2000 GMT X-MyDeja-Info: XMYDJUIDpetrock00 Newsgroups: comp.sys.mac.programmer.codewarrior,comp.sys.mac.programmer.codewarrior,codewarrior.mac X-Http-User-Agent: Mozilla/4.75 (Macintosh; U; PPC)