[En-Nut-Discussion] Is this a bug or a 'Feature' ?
ralph.mason at telogis.com
Thu Apr 3 10:12:47 CEST 2003
If the thread that allocates the memory also frees the memory then it should
be possible here (in debug) to track memory usage per thread. Combine that
with the thread kill I did and I think there is a way to put in checks for
this kind of stuff.
Basically I am thinking of a memory pointer in the thread structure and the
allocate allocating another pointer size with each allocation and chaining
these up as memory is allocated, freeing as it is freed. When the thread
exits is traces left over memory blocks somewhere (and possibly frees them?)
On this note - has anyone had nut application that have run for months on
> -----Original Message-----
> From: en-nut-discussion-admin at egnite.de
> [mailto:en-nut-discussion-admin at egnite.de]On Behalf Of Mike Cornelius
> Sent: Thursday, 3 April 2003 5:41
> To: en-nut-discussion at egnite.de
> Subject: [En-Nut-Discussion] Is this a bug or a 'Feature' ?
> Hi All,
> I've found that the following code:-
> while (1)
> addr = inet_addr("192.168.1.117");
> loc_sock = NutTcpCreateSocket();
> loc_sock->so_read_to = 1000;
> if(NutTcpConnect(loc_sock, addr, MODBUS_PORT) == 0)
> // Stuff that doesn't matter
> Does not actually free the memory associated with the socket if
> NutTcpConnect() fails, particularly in the case where I disconnect the
> ethernet cable.
> NutTcpCloseSocket() calls NutTcpStateCloseEvent() and if sock->so_state ==
> TCPS_CLOSED at that time NutTcpStateCloseEvent() sets:-
> sock->so_last_error = ENOTCONN;
> Which sort of makes sense but requires the application to check the
> NutTcpCloseSocket() return value and 'manually' call NutTcpDestroySocket()
> otherwise we've got a memory leak.
> To me it makes sense to modify NutTcpStateCloseEvent() as follows: -
> case TCPS_CLOSED: // <-New Case
> case TCPS_LISTEN:
> case TCPS_SYN_SENT:
> * No connection yet, immediately destroy the socket.
> I wonder what others (Particularly Harald) think...
> Mike Cornelius Internet: mikec at calldirect.com.au
> Call Direct Cellular Solutions Phone: +61 2 99-65-75-85
> Level 1 8-22 West St North Sydney FAX: +61 2 99-65-75-90
> NSW 2060 Australia URL: http://www.calldirect.com.au
> En-Nut-Discussion mailing list
> En-Nut-Discussion at egnite.de
> Incoming mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.461 / Virus Database: 260 - Release Date: 10/03/2003
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.461 / Virus Database: 260 - Release Date: 10/03/2003
More information about the En-Nut-Discussion