"Tony Yat-Tung Cheung" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Hi,
>
> I've found the following codes will cause a 1KB memory leak (Dynamic
RAM
> Heap) on a real Treo 650 device (GSM unlocked version).
>
> The codes simply  opens the NetLib, creates a socket, closes the
socket
> and then closes the NetLib. However, every time the codes are run,
it
> reduces the free Dynamic RAM Heap size by around 1KB.
>
> Is it a known problem? Any workaround? Thank you.
>
> {
>      UInt16 libRefNum;
>      Err err;
>
>      {
>          UInt16 netIFErr=0;
>
>          err = SysLibFind("Net.lib", &libRefNum);
>          ErrFatalDisplayIf(err != errNone, "Error");
>          err = NetLibOpen(libRefNum, &netIFErr);
>          ErrFatalDisplayIf(err != errNone, "Error");
>      }
>
>      {
>          NetSocketRef sock=-1;
>          Err err;
>          Int16 rc;
>
>          sock = NetLibSocketOpen(libRefNum,
>                                  netSocketAddrINET, //AF_INET
>                                  netSocketTypeStream, //SOCK_STREAM
>                                  0,
>                                  SysTicksPerSecond() * 5,
>                                  &err);
>          ErrFatalDisplayIf(sock == -1, "Error");
>
>          rc = NetLibSocketClose(libRefNum, sock, SysTicksPerSecond()
*
> 5, &err);
>          ErrFatalDisplayIf(rc == -1, "Error");
>      }
>
>      err = NetLibClose(libRefNum, false);
>      ErrFatalDisplayIf((err != errNone && err != netErrStillOpen),
"Error");
> }
>
> Tony
>
> Tony Yat-Tung Cheung wrote:
> > Hi,
> >
> > I am testing my networking application on the Treo 650. I've found
that
> > approximately 1KB of heap memory is lost every time my application
run
> > once, which includes opening a connection to a server and
disconnecting
> > the connection.
> >
> > The problem only occurs with the Treo 650, I have tested with the
T3 and
> > Treo 600 with no such problem. I also tested the application on
the Palm
> > Emulator (OS 4.0) with no memory leak detected.
> >
> > I am also testing it on a real Treo 650 device using GPRS
connection. I
> > also found that when I close the GPRS connection, all those lost
heap
> > memories (1KB each time) are all recovered.
> >
> > Does anyone have any idea what might have gone wrong? Is there any
thing
> > special with the Treo 650 networking stacks that may introduce
memory
> > leaks not possible with other devices?
> >
> > Thank you very much.
> >
> > Tony Cheung
> >
>

What do you see happening if you use "err = NetLibClose(libRefNum,
true);"  ?  Do you still lose 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