[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lwip-devel] [bug #60758] Provide a way to release all memory

From: R. Diez
Subject: [lwip-devel] [bug #60758] Provide a way to release all memory
Date: Wed, 9 Jun 2021 14:55:06 -0400 (EDT)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:89.0) Gecko/20100101 Firefox/89.0


                 Summary: Provide a way to release all memory
                 Project: lwIP - A Lightweight TCP/IP stack
            Submitted by: rdiez
            Submitted on: Wed 09 Jun 2021 06:55:04 PM UTC
                Category: None
                Severity: 3 - Normal
              Item Group: Feature Request
                  Status: None
                 Privacy: Public
             Assigned to: None
             Open/Closed: Open
         Discussion Lock: Any
         Planned Release: None
            lwIP version: git head



I recently asked the following question in the lwip-users mailing list:

How to release all memory to track leaks

>From the answers I got, I gather that there is no way to do that at the
moment, so I decided to create a feature request for it.

I have a bare-metal (Newlib, no threads) firmware that uses lwIP and its httpd
server to provide a simple web interface.

The firmware is actually quite complex in other areas. I am trying to identify
and track down eventual memory leaks, so I implemented a "shutdown" command in
the debug console that releases all resources and checks the remaining
allocated bytes with mallinfo().

I suspect some of the remaining memory "leaks" belong to lwIP and/or its httpd
server, because they only come up after having downloaded the web page once.
They probably are not real leaks, because memory usage does not grow over

It is hard to say, because it is not easy to track memory allocations with
Newlib. Or at least I haven't mastered it yet.

In any case, I would like lwIP to release all memory on shutdown, in order to
locate any memory leaks in other parts. The trouble is, there are routines
like lwip_init() and httpd_init(), but no xxx_terminate() counterparts.

I tried removing all interfaces with netif_remove(), but that is apparently
not enough.

This is a serious limitation, because it effectively prevents me from
automatically detecting memory leaks in my firmware.

Other libraries have identified this need and provided a way to do it. For
example, glibc provides __libc_freeres, and GCC's C++ support library provides

There is another feature request that is somewhat related:

Clean shutdown and restart support

That is about providing a complete lwIP shutdown and restart, but I do not
need to go that far. I just need dynamic memory to be released, which could be
much easier to achieve.

I wonder whether one could artificially move the internal time forwards (far
in the future) and tick all lwIP state machines once more after all interfaces
have been removed. Could that effectively trigger all possible timeouts and do
a complete memory release all over the place? Or would such a trick still not
be enough?


Reply to this item at:


  Message sent via Savannah

reply via email to

[Prev in Thread] Current Thread [Next in Thread]