Memory leak in TApdWinsockPort
Brought to you by:
tpsfadmin
I think there is a memory leak in TApdWinsockPort when using tracing.
When you set tracing to tlOn it calls InitTracing in the dispatcher which allocates memory to the TraceQueue buffer. I then set tracing to tlDump which then successfully sets tracing to tlOff but does not appear to free the buffers memory.
Logged In: YES
user_id=571803
Originator: YES
I forgot to mention that I am using 4.07 RC2 and Turbo Delphi 2006 in case this makes a difference.
Logged In: YES
user_id=84969
Originator: NO
The TraceQueue buffer gets allocated in TApdBaseDispatcher.InitTracing only if TraceQueue <> nil. That is, if it has not been previously allocated. If it is already allocated, it won't be reallocated. Hence, no memory leak. The memory if free'd in TApdBaseDispatcher.AbortTracing after which TraceQueue is set to nil. As nearly as I can tell, AbortTracing gets called from DumpTracePrim before it exits. Again, I don't see how there can be a memory leak. Unless you are constantly creating and destroying the port component without dumping the trace.
Hi,
I use Version 4.07 with Delphi 2006, and after check potential memory leak in my software I found same issue with tracing option:
I open my comport, I turn on the tracing (tlOn)....software is running....when I exit I had a memory leak (see FastMM report below).
So to solve this issue I need to turn tracing to off (tlOff) before close and release the comport.
FASTMM4 report:
--------------------------------2009/10/10 19:23:16--------------------------------
A memory block has been leaked. The size is: 24740
This block was allocated by thread 0x50C, and the stack trace (return addresses) at the time was:
40D776 [FastMM4.pas][FastMM4][FastMM4.DebugAllocMem][6929]
40304A [system.pas][System][System.AllocMem][2546]
63E8CB [AwUser.pas][AwUser][AwUser.TApdBaseDispatcher.InitTracing][3586]
644998 [AdPort.pas][AdPort][AdPort.TApdCustomComPort.InitTracing][2371]
642D59 [AdPort.pas][AdPort][AdPort.TApdCustomComPort.SetTracing][1002]
64425D [AdPort.pas][AdPort][AdPort.TApdCustomComPort.InitPort][2064]
4051A1 [system.pas][System][System.@CallDynaInst][9179]
643075 [AdPort.pas][AdPort][AdPort.TApdCustomComPort.SetOpen][1118]
7215F9 [Unit_ComPorts.pas][Unit_ComPorts][Unit_ComPorts.TModule_ComPorts.InitPorts][72]
7E3A8EAB [Unknown function at DefWindowProcW]
7E39882A [Unknown function at GetDC]
The block is currently used for an object of class: Unknown
The allocation number is: 371493
Current memory dump of 256 bytes starting at pointer address 7EF254B0:
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .