slang-users mailing list

[2001 Date Index] [2001 Thread Index] [Other years]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]

RE: S-Lang Exit procedure


I know it is not a real leak... (That is why I didn't ask 6 months ago!)
Sorry for my inaccurate use of term...

Of what I know I agree that there is NO leak into S-Lang.

I was only cleaning-up my code and I asked myself and everybody if there was
an exit procedure in S-Lang that dosen't terminate S-Lang's host program.

It will wait for version 2.0

Thanks for the answer.

> -----Original Message-----
> From: John E. Davis [mailto:davis@xxxxxxxxxxxxx]
> Sent: 10 avril, 2001 16:02
> To: fguimond@xxxxxxxxxx; slang-workers@xxxxxxxxxxxxxxxxxxxxxxxxxx
> Subject: Re: S-Lang Exit procedure
> 
> 
> Francois Guimond <fguimond@xxxxxxxxxx> wrote:
> >Is there any way to free all the stuff allocated by :
> > 
> >SLang_init_all (); 
> >SLadd_intrin_fun_table (My_Intrinsics, NULL); 
> >SLadd_intrinsic_variable ("I_Variable", &I, SLANG_INT_TYPE, 0));
> 
> Not until version 2.0.
> 
> >I want to exit my program without memory leak...
> >In the documentation and slang.h, I only found :
> > 
> >SLang_exit_error (char *, ...);
> >
> >But I still have tons of leak.
> 
> As far as I know, there are no real memory leaks in the slang library.
> For example, here is a program with a real memory leak:
> 
> void leak ()
> {
>    char *ptr = malloc (256);
> }
> 
> int main ()
> {
>     leak ();
>     leak ();
> }
> 
> That is, each time leak is called, 256 bytes are lost during program
> execution.   However, using
> 
> char *ptr;
> void leak ()
> {
>    if (ptr != NULL) free (ptr);
>    ptr = malloc (256);
> }
> 
> does produce a leak since one call call 'leak' many times 
> without losing
> memory.
> 
> But note one thing: After main returns, the global variable 'ptr' will
> point to an allocated block of 256 bytes, which some over zealous
> memory checkers will flag as a leak.  However, as illustrated above,
> this is not a true leak.  Hence, programs such as purify, which is my
> favorite checker, do not report such false leaks.  Of course, this is
> a false leak as long as your OS deallocates memory allocated by the
> process after the process exits.
> 
> --John
> 

[2001 date index] [2001 thread index]
[Thread Prev] [Thread Next]      [Date Prev] [Date Next]