This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Think I discovered a problem with NDK Heap usage

Other Parts Discussed in Thread: SYSBIOS

Using ndk_2_24_03_35 (this is also in ndk_2_24_00_11, not sure where else), but I believe the function "int SockShutdown( HANDLE h, int how )" in sock.c

needs to also flush the transmit buffer as well as the receive buffer:

/* Perform read flush */
if( ps->hSBRx )
     SBFlush( ps->hSBRx, 1 );

/* Perform transmit flush (ADDED) */
if( ps->hSBTx )
     SBFlush( ps->hSBTx, 1 );

If this is not done, the heap will grow every time a connection is shutdown.

I've added this and now my heap remains the same size from before and after a connection is created and then shutdown.

-Ed Francy

  • Ed,

    By chance, I'm in the middle of looking into a possible memory leak issue. I'll have to look at this in more detail to confirm.

    In the meantime, can you please describe the original symptoms you were seeing that led you to look for/find this? Were you trying to close out some sockets, and noticed that memory was not being freed?

    Thanks,

    Steve
  • Hi,
    I was limited to only 48 connect/disconnect cycles on a socket, then I'd receive this error from the debugger:

    ti.sysbios.heaps.HeapMem: line 307: out of memory: handle=0x841ed718, size=8200

    So I used the ROV to check the heap. I saw the totalFreeSize drop each time a shutdown() was processed, so I followed that...
    Sure enough I saw that the code allocates memory for both the Rx buff and the Tx when creating a connection, but doesn't free it on the shutdown.


    -ed
  • Ok, thanks Ed. I'll keep you updated, but this seems like a bug to me.

    Steve