[futurebasic] Re: [FB] Memory leak?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : October 2001 : Group Archive : Group : All Groups

From: jonathan <jonnnathan@...>
Date: Wed, 17 Oct 2001 16:34:15 +0200
le 2001/10/17 15:39, tedd à tedd@... a écrit :

> Please explain if there are other types of memory leaks.

your description is exact, except in your description the agent responsible
for the leak is murphy. there was a [in]famous case like this in applescript
at one point [just ask alain]. however the more usual culprit is sitting
near the keyboard.

for example, suppose that in routine 'a', i forget to free up 4K of memory;
that is, i make a handle and don't dispose of it. it sits dangling in
memory. this shouldn't be a problem as when the app gets closed it'll get
freed by the memory manager with everything else.

however if i call 'a' three or four times, i now have about 12 k sitting
frozen in memory. in my case i was calling a routine about 1200 times before
it crashed. had i had a memory leak, i could have been in the situation
where i was slowly cutting down the memory available to my app, like a leak
slowly filling the cellar, until finally the app belly-ups and can't get any
memory to do anything any more.

this is why programmers should be aware of the question. in an ideal world,
you always dispose of any memory you allocate to yourself [in ideal 'modern'
languages [generally object], you don't bother, the garbage collection
allocates and frees as it goes along, thus, as you implied, passing the
responsability on to the compiler manufacturer]. in the real world, we tend
to program logically, but in an extreme or specific case the flow may not go
as we intended - the old "do what i want, not what i said" programming
dilemma - and the memory will not freed. thus the need for tools to help
track these beasties down.

in my case, i tracked it down. it wasn't a memory leak. i checked usage
before and after this routine, and it didn't change. in fact i was apssing
the wrong parameter to a toolbox call, and after a while it got lost, but
not initially, which is why it led me astray. i squashed it this morning and
i'm real happy. native dragging in lochNess is 50% complete. should be
finished for christmas [yes, but which year?].

:-j