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.

NDK Error - SB6New: Buffer OOM

Hi,

I have problems with NDK IPv6, when I connect and disconnect several times to IPv6 socket int TCP port. At one point, the TI-RTOS breaks down and shows the error:

mmBulkAlloc(): could not allocate memory.
00292.581 out of memory: handle=0x0, size=536932020
00292.581 SB6New: Buffer OOM

I've been searching in the code the root of the problem. I found that every time a client connects to IPv6 socket(TCP), a TX and RX buffer are allocated. sock6.c:

/* Allocate Rx socket buffer */
if( Type == SOCK_STREAM )
    {
        if( !ps->RxBufSize )
            ps->RxBufSize = SOCK_TCPRXBUF;
        ps->hSBRx = (HANDLE)SB6New( ps->RxBufSize, SOCK_BUFMINRX, SB_MODE_LINEAR );
    }
...
/* Allocate memory for the transmit buffer. */
ps->hSBTx = (HANDLE)SB6New( ps->TxBufSize, SOCK_BUFMINTX, SB_MODE_LINEAR );

But when the client disconnects the buffer is not released:

fdClose(socket6) [my app call] -> Sock6Close() [is not always called] -> Sock6IntAbort() [is never called] -> SB6Free()

/* Free the Rx and Tx Buffers */
    if( ps->hSBRx )
        SB6Free( ps->hSBRx );
    if( ps->hSBTx )
        SB6Free( ps->hSBTx );

As the memory is not freed, the system always breaks. 

I'm using an EK-TM4C1294XL, tirtos_tivac_2_01_00_03, ndk_2_23_01_01, bios_6_40_03_39, TI v5.1.6 compiler and CCSv6.

Thanks,

Vini