| View previous topic :: View next topic |
| Author |
Message |
Larry Johnson Guest
|
Posted: Thu Sep 25, 2003 10:56 pm Post subject: WinHelpViewer Initialization Memory Leak |
|
|
I am using BCB6.0 and I am getting a Code Guard Memory Leak Error
Winhelpviewer::initialzation(). Below is the message from codegaurd and some
information from a web site which discusses this error. This error seems to
be in both BCB and Delphi but was fixed in Delphi. Is this error still part
of BCB6.0 or do I need to mamually free is memory? How can I free this
memory when exiting my application?
Thanks.
Larry.
From Code Guard
=============================
The Memory block (0x01B8692C)[size: 36 bytes] was allocated with SysGetMem
System::__linkproc__GetMem(int)
Winhelpviewer::initialzation()
=============================
The information below is from this web site.
http://www.automatedqa.com/support/leaksd6.asp
File: WinHelpViewer.pas
Procedure: initialization
Line #: 656
Description: A reference to the FHelpManager object created within
initialization isn't removed.
Type: Reference leak
Fixed: Yes, Delphi 7
Workaround
unit WinHelpViewer;
....
initialization HelpViewer := TWinHelpViewer.Create;
HelpIntfs.RegisterViewer(HelpViewer, HelpViewer.FHelpManager); //<-- The
reference is created within this function
...
unit HelpIntfs;
....
function RegisterViewer(newViewer: ICustomHelpViewer;
out Manager: IHelpManager): Integer;
begin
if not Assigned(HelpManager) then
HelpManager := THelpManager.Create;
...
end;
....
finalization
//Replace the source line "if Assigned(HelpManager) then HelpManager :=
nil;" with the following:
if Assigned(HelpManager) then
begin
HelpManager._Release;
HelpManager := nil;
end;
|
|
| Back to top |
|
 |
Duane Hebert Guest
|
Posted: Mon Sep 29, 2003 1:47 pm Post subject: Re: WinHelpViewer Initialization Memory Leak |
|
|
"Larry Johnson" <Johnson222 (AT) ev1 (DOT) net> wrote
| Quote: | I am using BCB6.0 and I am getting a Code Guard Memory Leak Error
Winhelpviewer::initialzation(). Below is the message from codegaurd and
some
information from a web site which discusses this error. This error seems
to
be in both BCB and Delphi but was fixed in Delphi. Is this error still
part
of BCB6.0 or do I need to mamually free is memory? How can I free this
memory when exiting my application?
|
I've been told that in BCB6 I can add winhelpviewer.pas to my project, make
the changes indicated and it
will work. It doesn't seem to. I've tried modifying the finalization part
and the internalshutdown procedure.
Either of these look like they should work but neither does. Any ideas from
TeamB?
|
|
| Back to top |
|
 |
Pete Fraser Guest
|
Posted: Mon Sep 29, 2003 2:04 pm Post subject: Re: WinHelpViewer Initialization Memory Leak |
|
|
It will only work if you are linking the VCL statically - otherwise it
always uses the functions in the DLL.
HTH Pete
"Duane Hebert" <spoo (AT) zowie_flarn (DOT) com> wrote
I've been told that in BCB6 I can add winhelpviewer.pas to my project, make
the changes indicated and it
will work. It doesn't seem to. I've tried modifying the finalization part
and the internalshutdown procedure.
Either of these look like they should work but neither does. Any ideas from
TeamB?
|
|
| Back to top |
|
 |
Duane Hebert Guest
|
Posted: Mon Sep 29, 2003 2:58 pm Post subject: Re: WinHelpViewer Initialization Memory Leak |
|
|
"Pete Fraser" <pete.fraser (AT) at (DOT) frasersoft.dot.net> wrote
| Quote: | It will only work if you are linking the VCL statically - otherwise it
always uses the functions in the DLL.
HTH Pete
|
Doh! I thought that I needed to enable dynamic rtl for codeguard in order
to prevent
confusion between memory managers. It doesn't seem to be the case with
BCB6. So
what is the recommended fix for this?
|
|
| Back to top |
|
 |
Pete Fraser Guest
|
Posted: Tue Sep 30, 2003 7:56 am Post subject: Re: WinHelpViewer Initialization Memory Leak |
|
|
I use Memproof (free) from Automated QA to check for leaks.
HTH Pete
"Duane Hebert" <spoo (AT) zowie_flarn (DOT) com> wrote
"Pete Fraser" <pete.fraser (AT) at (DOT) frasersoft.dot.net> wrote
| Quote: | It will only work if you are linking the VCL statically - otherwise it
always uses the functions in the DLL.
HTH Pete
|
Doh! I thought that I needed to enable dynamic rtl for codeguard in order
to prevent
confusion between memory managers. It doesn't seem to be the case with
BCB6. So
what is the recommended fix for this?
|
|
| Back to top |
|
 |
Duane Hebert Guest
|
Posted: Tue Sep 30, 2003 1:02 pm Post subject: Re: WinHelpViewer Initialization Memory Leak |
|
|
"Pete Fraser" <pete.fraser (AT) at (DOT) frasersoft.dot.net> wrote
| Quote: | I use Memproof (free) from Automated QA to check for leaks.
HTH Pete
|
I use MemProof, Memory Sleuth and CodeGuard. The first two are better than
codeguard at
detecting leaks IMO but CG does a pretty good job at bounds checking and
such. I pretty
much blew it off though. It's really annoying that Borland won't fix such
trivial problems.
|
|
| Back to top |
|
 |
Larry Johnson Guest
|
Posted: Tue Sep 30, 2003 9:21 pm Post subject: Re: WinHelpViewer Initialization Memory Leak |
|
|
To Duane Hebert,
I did not understand how you fixed this problem. What you wrote was a little
over my head. Can you please explain in simple language. Do I need to open
the winhelpviewer.pas and make a code change? Do I just make a change in
the compiler settings?
Thanks
Larry Johnson.
"Duane Hebert" <spoo (AT) zowie_flarn (DOT) com> wrote
| Quote: |
"Pete Fraser" <pete.fraser (AT) at (DOT) frasersoft.dot.net> wrote in message
news:3f793e18 (AT) newsgroups (DOT) borland.com...
I use Memproof (free) from Automated QA to check for leaks.
HTH Pete
I use MemProof, Memory Sleuth and CodeGuard. The first two are better
than
codeguard at
detecting leaks IMO but CG does a pretty good job at bounds checking and
such. I pretty
much blew it off though. It's really annoying that Borland won't fix such
trivial problems.
|
|
|
| Back to top |
|
 |
Duane Hebert Guest
|
Posted: Wed Oct 01, 2003 1:12 pm Post subject: Re: WinHelpViewer Initialization Memory Leak |
|
|
"Larry Johnson" <Johnson222 (AT) ev1 (DOT) net> wrote
| Quote: | To Duane Hebert,
I did not understand how you fixed this problem. What you wrote was a
little
over my head. Can you please explain in simple language. Do I need to open
the winhelpviewer.pas and make a code change? Do I just make a change in
the compiler settings?
|
I didn't get it to work here. The idea though (I think) is to add
winhelpviewer.pas to your project,
turn off "Use Dynamic RTL" in the linker settings and add code in the
finalization section
to free the helpviewer. I think this is supposed to work:
initialization
HelpViewer := TWinHelpViewer.Create;
HelpIntfs.RegisterViewer(HelpViewer, HelpViewer.FHelpManager);
WinHelpTester := nil;
finalization
if Assigned(HelpViewer.FHelpManager) then
begin
HelpViewer.InternalShutDown;
end;
if Assigned(WinHelpTester) then
begin
WinHelpTester := nil;
end;
HelpViewer.FreeInstance; // adding these two lines is supposed to
do it
HelpViewer := nil;
end.
This didn't work for me though. Actually, it seemed to for a second but it
didn't. Maybe
Remy or one of the other VCL gurus can give you better information. Once I
add winhelpviewer
to my project, it builds a bunch of other files. If one of them happens to
be an rc file I could
be getting caught by QC2072 bug. It may also be affected by my setting "use
debug libraries"
on in the linker options but this is necessary to debug the VCL.
|
|
| Back to top |
|
 |
Duane Hebert Guest
|
Posted: Wed Oct 01, 2003 1:52 pm Post subject: Re: WinHelpViewer Initialization Memory Leak |
|
|
initialization
HelpViewer := TWinHelpViewer.Create;
HelpIntfs.RegisterViewer(HelpViewer, HelpViewer.FHelpManager);
WinHelpTester := nil;
finalization
if Assigned(HelpViewer.FHelpManager) then
begin
HelpViewer.InternalShutDown;
end;
if Assigned(WinHelpTester) then
begin
WinHelpTester := nil;
end;
HelpViewer._Release;
HelpViewer := nil;
end.
This seems to fix the problem if I disable "Use debug libraries" as well
as "use dynamic rtl" Maybe someone will correct me, but it seems that if
I use the debug libs, it links the dll. If I don't use debug libs, CG
doesn't detect
leaks in the VCL (like unfreed TStringList) So basically, without being
able to
recompile the dll, it can't be fixed. This is 2 lines of code.
|
|
| Back to top |
|
 |
|