LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   Memory leak in socket operations. (https://www.linuxquestions.org/questions/linux-networking-3/memory-leak-in-socket-operations-667275/)

upakul 09-03-2008 06:01 AM

Memory leak in socket operations.
 
Hi all,

I am creating udp sockets to receive packets but i dont call any recv() so the packets must be lying in the udp queue. Now when I close the socket and open a new socket (with reuseaddr sockopt) then it results in memory leaks.

My question is that when closing or shutting down the sockets, isnt the udp queue cleared up? Secondly is there any way to forcefully clear up the memory related to a socket??

Thanks in anticipation!!

Matir 09-03-2008 09:26 AM

Unless you have a version of glibc that is bugged (fairly unlikely), then closing the socket will free any system-allocated structures related to the socket. What tool are you using to identify the memory leak? Also, if you don't call recv(), how are you receiving your data?

upakul 09-03-2008 10:41 AM

Hi Matir,

Thanks for your reply. Actually I just hit at it by chance. When I open a socket, recv() and close ... and so on there is no memory leak. But if I just open a socket, and close it and so on(with reuseaddr) then memory is not freed up. I thought this is not the expected behavior so thought of putting across the query.

I am using /proc/meminfo to check the memory info.

I will do some more experiments and update you.


All times are GMT -5. The time now is 09:54 PM.