"Roel Wijmans" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> I seem to be having a memory leak when running a database of a
memory card. The emulator doesn't pick it up though. All is running
fine if the database runs of the device, but as soon as i run it of
the memory card, it i start loosing memory. I can't figure out what
i'm doing wrong.. I'm closing the database once finished with it. And
since the emulator doesn't give me any memory leaks, i'm assuming that
all related memory has been cleared. As the memory loss doesn't happen
when running on the device, i assume it has to do with my VFS
functions.
>
> Is there something i'm missing?
>
> I'm using the following code to open the database on the memory
card...
>
> FileRef theDatabaseFile;
>
> static void OpenDatabaseVFS(Char *theDatabaseName)
> {
> UInt32 volumeIterator;
>
> theDatabaseFile = NULL;
>
> volumeIterator = vfsIteratorStart;
> while ( (volumeIterator != vfsIteratorStop) &&
> (VFSVolumeEnumerate (&volumeRefNum, &volumeIterator) == errNone) )
> if ( (theDatabaseFile = FindFile (volumeRefNum, "/PALM/
Launcher",theDatabaseName)) != NULL )
> volumeIterator = vfsIteratorStop;
> else
> {
> if( StrCaselessCompare (theDatabaseName, databaseName) == 0)
> {
> //do something to display error can't find database
> }
> }
>
> }
>
> static FileRef FindFile (UInt16 volRefNum, Char *directory, Char
*theDatabaseName)
> {
>     FileInfoType       fileinfo;
>     FileRef             dirRef, fileRef;
>     UInt32              dirIterator;
>     UInt16             length;
>
>     fileRef = NULL;
>
>     if ( VFSFileOpen (volRefNum, directory, vfsModeRead, &dirRef) ==
>                 errNone )
>         {
>         StrCopy (pathname, directory);
>
>         if ( StrCompare (pathname, "/") != 0 )
>             StrCat (pathname, "/");
>
>         length = StrLen (pathname);
>
>         fileinfo.nameP      = pathname + length;
>         fileinfo.nameBufLen = sizeof pathname - length;
>
>         dirIterator = vfsIteratorStart;
>
>         while ( (dirIterator != vfsIteratorStop) &&
>                    (VFSDirEntryEnumerate (dirRef, &dirIterator,
&fileinfo)
>                       == errNone) )
>             {
>             if ( fileinfo.attributes & vfsFileAttrDirectory )
>                 fileRef = FindFile (volRefNum, pathname,
theDatabaseName);
>             else if ( StrCaselessCompare (fileinfo.nameP,
theDatabaseName) == 0)
>                 VFSFileOpen (volRefNum, pathname, vfsModeRead,
&fileRef);
>
>             if ( fileRef != NULL )
>                 dirIterator = vfsIteratorStop;
>             }
>
>         VFSFileClose (dirRef);
>         }
>
>     return fileRef;
> }
>
> And i just close the open fileRef with VFSFileClose.
>
> Can anyone point me in the right direction
>
> Roel
>

If you are leaking storage heap memory, the emulator will not flag it.
Only flags leaks in the dynamic heap.

Ralph



-- 
For information on using the Palm Developer Forums, or to unsubscribe, please 
see http://www.palmos.com/dev/support/forums/

Reply via email to