lwip-devel
[Top][All Lists]
Advanced

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

RE : [lwip-devel] Memory leak for timeouts


From: Frédéric BERNON
Subject: RE : [lwip-devel] Memory leak for timeouts
Date: Tue, 6 Nov 2007 10:32:28 +0100

It's a known problem, which is not really consider as a lwIP problem, but more 
as a port problem:

If your OS provide you an TLS feature, it should provide a way to call a 
cleanup function when a thread is terminated, and in this function, you can 
call your specific port "sys_thread_exit" or "sys_thread_free". Or you can call 
it explicitly in one of the last instructions of your thread.

I don't think that lwIP could provide a such support, since a thread can use 
several sockets/netconn, so, we can't even do such cleanup processing in 
lwip_close/netconn_close. But most of time, on embedded targets, I think the 
number of threads is limited and static, and not dynamic. So, the "memory leak" 
is more a "memory use". Perhaps I'm wrong.

Note that in CVS head, the problem should only appears with "select" calls (and 
PPP).
  
====================================
Frédéric BERNON 
HYMATOM SA 
Chef de projet informatique 
Microsoft Certified Professional 
Tél. : +33 (0)4-67-87-61-10 
Fax. : +33 (0)4-67-70-85-44 
Email : address@hidden 
Web Site : http://www.hymatom.fr 
====================================
P Avant d'imprimer, penser à l'environnement
 


-----Message d'origine-----
De : address@hidden [mailto:address@hidden De la part de Marc CHALAND
Envoyé : mardi 6 novembre 2007 09:56
À : lwip-devel
Objet : [lwip-devel] Memory leak for timeouts


Hello,

We still port lwip to L4. As lwip api msg is synchronous, we decided to adopt 
the following architecture :
- one thread for each client process
- one thread per socket
- one thread for each select call.

As a consequence, we have many threads created. By doing some tests, we've 
found a memory leak around timeouts. Indeed, sys_timeouts should provide memory 
local to each thread. On L4, we use TLS (thread local
storage) : in each thread, if no TLS corresponding to sys_timeouts has been 
referenced, a malloc is done and is then referenced into TLS. But, this little 
chunk of memory is newer freed.

Today, we decided to fix this by creating a sys_thread_exit function which free 
the sys_timeout structure referenced into TLS. Is there another way we didn't 
find in lwip ? Should I propose a patch (sys.h) ? a bug ?

Regards
Marc


_______________________________________________
lwip-devel mailing list
address@hidden http://lists.nongnu.org/mailman/listinfo/lwip-devel

Attachment: Frédéric BERNON.vcf
Description: Frédéric BERNON.vcf


reply via email to

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