in sys_arch.c, within the lwip bindings, any time a thread is started with sys_thread_new, new memory is allocated from the Core Memory Manager, possibly leaking memory (if, for instance, PPP sessions are started, and stopped)
Attached is a patch that allows the threads to be declared on the default heap, then released, so that the memory can be reclaimed.
I see, how threads would be terminated? there is not a function that terminates a lwIP thread so that the memory could be recovered.
My way around this was to call chRegFirstThread and chRegNextThread to iterate through the thread registry and reap any threads with 0 refcounts. the ppp thread does indeed terminate when you call pppClose, in lwip version 1.4.1.