Board index » cppbuilder » How to suppress winhelpviewer resource leak in CodeGuard?

How to suppress winhelpviewer resource leak in CodeGuard?


2005-07-05 05:04:36 PM
cppbuilder42
I was not sure where to post this question about CodeGuard in BCB6 ... so I
thought I would try at the top...
I am getting a CodeGuard message:
memory block allocated with SysGetMem ... was never freed
System:__linkproc__ GetMem(int)
Winhelpviewer::initialization()
etc etc
Is there a way to turn off this particular error message via GodeGuard's
control panel? I looked but couldn't work out how to target a specific leak.
Also, does anyone know where this reference to Winhelpviewer might be coming
from? I haven't explicitely called it.
Any help would be much appreciated.
Thanks
--
Andrew Bond
Geocentrix
 
 

Re:How to suppress winhelpviewer resource leak in CodeGuard?

Andrew Bond wrote:
Quote
Is there a way to turn off this particular error message via
GodeGuard's control panel? I looked but couldn't work out how to
target a specific leak.

No.
Quote
Also, does anyone know where this reference to Winhelpviewer might be
coming from? I haven't explicitely called it.
It seems to be a leak in Borland's RTL. AFAICT it is a small one-off
leak although it usually turns up in pairs per loaded module and IIRC
goes away with dynamic RTL. Since it is small and Windows will reclaim
it when the process exits it's pretty safe to ignore it IMO.
--
Andrue Cope [TeamB]
[Bicester, Uk]
info.borland.com/newsgroups/guide.html
 

Re:How to suppress winhelpviewer resource leak in CodeGuard?

Andrew
Thanks for the quick response.
Quote
No.
As I suspected.
Quote
It seems to be a leak in Borland's RTL. AFAICT it is a small one-off
leak although it usually turns up in pairs per loaded module and IIRC
goes away with dynamic RTL. Since it is small and Windows will reclaim
it when the process exits it's pretty safe to ignore it IMO.
It doesn't go away with dynamic RTL (all my DLLs and EXEs are linked to
dynamic RTL).
Oh, well, it'll just have to annoy me until the next version of Builder...
Andrew
 

{smallsort}

Re:How to suppress winhelpviewer resource leak in CodeGuard?

Andrew Bond wrote:
Quote
Andrew

Thanks for the quick response.


>No.


As I suspected.


>It seems to be a leak in Borland's RTL. AFAICT it is a small one-off
>leak although it usually turns up in pairs per loaded module and IIRC
>goes away with dynamic RTL. Since it is small and Windows will reclaim
>it when the process exits it's pretty safe to ignore it IMO.


It doesn't go away with dynamic RTL (all my DLLs and EXEs are linked to
dynamic RTL).

Oh, well, it'll just have to annoy me until the next version of Builder...

Andrew


I'm also encountring this problem. But some times Code Guard doesnt
complain. May be the error is in CodeGuard.
Sabetay
 

Re:How to suppress winhelpviewer resource leak in CodeGuard?

I think this might be due to a bug in WinHelpViewer.pas. Try opening
WinHelpViewer.pas and looking for the following section of code:
--------------------
initialization
HelpViewer := TWinHelpViewer.Create;
HelpIntfs.RegisterViewer(HelpViewer, HelpViewer.FHelpManager);
WinHelpTester := nil;
finalization
if Assigned(HelpViewer.FHelpManager) then
begin
HelpViewer.InternalShutDown;
HelpViewer.FRefCount := 0; { I ADDED THIS LINE }
HelpViewer.Free; { I ADDED THIS LINE }
end;
if Assigned(WinHelpTester) then
begin
WinHelpTester := nil;
end;
end.
--------------------
The { I ADDED THIS LINE } comments denote the lines of code that you
should add. After doing so, add the file WinHelpViewer.pas, turn off "Use
Dynamic RTL", and rebuild the project. See if the problem is still there.
If that fails to help, then try doing the following in
WinHelpViewer.pas instead:
--------------------
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; { I ADDED THIS LINE }
HelpViewer := nil; { I ADDED THIS LINE }
end.
--------------------
I believe one of these workarounds has eliminated the issue in the
past. Unfortunately, at the moment I'm unable to go back and see which it
was. Bear in mind that even if this works, it's completely unofficial.
-- YH --
 

Re:How to suppress winhelpviewer resource leak in CodeGuard?

Quote
After doing so, add the file WinHelpViewer.pas, turn off "Use
Dynamic RTL", and rebuild the project. See if the problem is still there.
Sorry, minor typo here. It should read, "After doing so, add the modified
WinHelpViewer.pas to your project..."
 

Re:How to suppress winhelpviewer resource leak in CodeGuard?

"Yu-Chen Hsueh" < XXXX@XXXXX.COM >wrote in message news:42cc06e6$ XXXX@XXXXX.COM ...
Quote
>After doing so, add the file WinHelpViewer.pas, turn off "Use
>Dynamic RTL", and rebuild the project. See if the problem is still there.

Sorry, minor typo here. It should read, "After doing so, add the modified
WinHelpViewer.pas to your project..."
Unfortunately, if you turn off "Use Dynamic RTL", you're going to
have problems with codeguard. Either it's not going to detect
leaks in VCL objects or it's going to give you errors about different
memory managers being loaded.
I find it difficult to believe that Borland wouldn't issue a simple
patch to fix this as well as one to fix the resource file build bug.
These both seem trivial to repair.
 

Re:How to suppress winhelpviewer resource leak in CodeGuard?

Duane Hebert wrote:
Quote
I find it difficult to believe that Borland wouldn't issue a simple
patch to fix this as well as one to fix the resource file build bug.
These both seem trivial to repair.
The resource file build bug should probably have had a patch issused
but the Winhelp leak is not really worth the bother. It's only a small
one-off memory leak that exists for the duration of the lifetime of the
application.
--
Andrue Cope [TeamB]
[Bicester, Uk]
info.borland.com/newsgroups/guide.html
 

Re:How to suppress winhelpviewer resource leak in CodeGuard?

Yu-Chen Hsueh wrote:
Quote
>After doing so, add the file WinHelpViewer.pas, turn off "Use
>Dynamic RTL", and rebuild the project. See if the problem is still there.


Sorry, minor typo here. It should read, "After doing so, add the modified
WinHelpViewer.pas to your project..."


Yu-Chen,
Either workaround doesn't fix the error. I build the project exactly
like what you said and trace it.
Sabetay
 

Re:How to suppress winhelpviewer resource leak in CodeGuard?

"Andrue Cope [TeamB]" < XXXX@XXXXX.COM >wrote in message news:42cd0eb7$ XXXX@XXXXX.COM ...
Quote
The resource file build bug should probably have had a patch issused
but the Winhelp leak is not really worth the bother. It's only a small
one-off memory leak that exists for the duration of the lifetime of the
application.
Sure. But the problem with the Winhelp leak is that you get used
to seeing it. If you don't parse through it, you can miss real leaks
that are showing up after it. It's just a one line fix. Why not fix it?
I agree though that the resource problem is more serious but it's
not fixed either :-(
 

Re:How to suppress winhelpviewer resource leak in CodeGuard?

In article <42cdb77b$ XXXX@XXXXX.COM >,
"Duane Hebert" < XXXX@XXXXX.COM >wrote:
Quote
Sure. But the problem with the Winhelp leak is that you get used
to seeing it. If you don't parse through it, you can miss real leaks
that are showing up after it. It's just a one line fix. Why not fix it?
It is possible that they fixed it in Delphi. There have been three
revisions since BCB 6 was released.
--
-David
 

Re:How to suppress winhelpviewer resource leak in CodeGuard?

Hi,
Quote
should add. After doing so, add the file WinHelpViewer.pas, turn off "Use
Dynamic RTL", and rebuild the project. See if the problem is still there.
I think you mean to suggest to turn OFF use of packages. "Use dynamic
RTL" refers to the C/C++ RTL. Turning OFF use of packages, links
statically to the VCL (and the VCL RTL) which means overriding
a unit can be accomplished.
--Craig
 

Re:How to suppress winhelpviewer resource leak in CodeGuard?

Quote
I think you mean to suggest to turn OFF use of packages. "Use dynamic
RTL" refers to the C/C++ RTL. Turning OFF use of packages, links
statically to the VCL (and the VCL RTL) which means overriding
a unit can be accomplished.
You're absolutely right, I meant "Build with runtime packages" on the
Packages tab of the Project Options. My apologies for the goof-up.