Hello Nandan,
You don't have to allocate the packet as this is done automatically by nx_tcp_socket_receive API. Your rcv_packet_ptr pointer is overwritten by receive function and hence, you're never releasing the packet you allocated originally.
Regards