[futurebasic] Re: [FB] NavServices: Is there a memory leak?

Message: < previous - next > : Reply : Subscribe : Cleanse
Home   : February 2002 : Group Archive : Group : All Groups

From: Herbie Gluender <H.Gluender@...>
Date: Sun, 03 Feb 2002 14:58:32 +0100
Dear Robert,

thank you for your prompt and kind help.

> Early versions of NavLibrary were notoriously buggy. Perhaps this explains your findings?

Obviously, yes!

Here is what I could find out with the help of your code and
by using my code under OS9.1.

From the log produced by your code I conclude that you use
NavLib 2.0.2 (comes with OS9.2 ?).

Your code:
'---------------
local fn ChooseFileObject
dim as OSErr            err
dim as NavReplyRecord   reply
err = fn NavChooseObject(=0, reply, =0, _nil, _nil, =0)
err = fn NavDisposeReply(reply)
end fn


dim as long j, freeBytes, maxBlock
window 1
print "NavLibraryVersion " hex$( fn NavLibraryVersion )
print "_freeBytes", "_maxAvail"
print
for j = 1 to 7
freeBytes = mem( _freeBytes )
maxBlock  = mem( _maxAvail )
fn ChooseFileObject
freeBytes = freeBytes - mem( _freeBytes )
maxBlock  = maxBlock  - mem( _maxAvail )
print freeBytes, maxBlock, "lost"
next
do
handleevents
until 0
'---------------

Your results:
The output on my Mac, showing _no_ progressive memory leak is:

NavLibraryVersion 02028000
_freeBytes      _maxAvail

 2704            4560           lost
 80              80             lost
 0               0              lost
 0               0              lost
-16             -16             lost
 0               0              lost
 0               0              lost

***********************************************************



With NavLib 1.1.0 (comes with OS8.6) your code signals a
severe loss of free memory.
With NavLib 2.0.1 (comes with OS9.1) I get results
comparable to yours with NavLib 2.0.2.

Finally, I went back to my code and observed it with "The
Memory Mine™":

LOCAL MODE
CLEAR LOCAL FN ChooseFileObject
'--------------------------------
DIM AS OSErr             err, dc
DIM AS LONG            @ dummy
DIM AS NavReplyRecord    reply

MaxApplZone                           ' see comment below
err = FN NavChooseObject(=0, reply, =0, _nil, _nil, =0)
dc  = FN NavDisposeReply(reply)
dc  = FN MaxMem(dummy)                ' compacts the heap
END FN = err


Leaks per call, according to "The Memory Mine™":

                             NavLib 1.1.0      NavLib 2.0.1
If the dialog is canceled:      32 bytes         0 bytes
If a file object is chosen:    128 bytes         0 bytes


********************
*                  *
* FINAL QUESTIONS  *
*                  *
********************

Where do I find "NavigationLib"?
Is it integrated to the System or is it a System Extensions
named differently from "NavigationLib" (if yes, how?) ?


*****************
*               *
* FINAL REMARK  *
*               *
*****************

A different and less important problem with NavDialogs is
their hunger for memory. Here is what I found on Apple's Website:

"Navigation Services is able to make a reasonable estimate
of the minimum amount of memory it will need to display a
browsing dialog. If this amount of memory is not available,
the call returns memFullErr without any on-screen evidence
of the failure. If your application failed to call
MaxApplZone before calling Nav, Nav will be fooled into
believing your heap is tiny or nearly full. MaxApplZone is
an important part of a balanced breakfast. Call it."

Thank you again Robert.

With very best regards,


Herbie
*************************************************
H.Glu@...