- This topic has 7 replies, 2 voices, and was last updated 3 years, 1 month ago by .
Viewing 4 reply threads
Viewing 4 reply threads
- You must be logged in to reply to this topic.
Hello,
Seems smart events has the same memory leak as native transport had ?
I’ve checked the code and the KBMMWFinalize runs on the application shutdown so i guess it’s interface leak.

Hi,
As far as I can see it is TkbmMWEvents that are leaked?
It is usually a singleton, unless you defined it yourself somewhere in your code?
Have you tried to issue a kbmMWShutdown before closing your application?
/Kim
Hello!
Yes! Here’s the code:
procedure TFormMain.FormClose(Sender: TObject; var Action: TCloseAction);
begin
CommonServer.doServerTerminate;
kbmMWShutdown;
end;
btw, i’m not using smartevents at all in my app!
Oh! i found i had a “kbmMWSmartEvent” declaration in one of my units that caused this. So even if you don’t use the SmartEvent declaring the unit causes this. Removed and the leaks gone!
Yes, adding kbmMWSmartEvent to the uses clause makes a singleton Event variable available, which is used for subscribing for events and notifying others about events happening.
/Kim
Can you free this upon finalization or needed to do it manually ?
It does indeed clean it up at finalization, if the depending units have first been finalized.
It is all governed by the kbmMWDependency unit.
If it does not call the RunFinalization procedure in the kbmMWSmartEvent.pas unit during shutdown, there is something preventing it to do so.
If you can provide a (small) sample not requiring 3rdparty (except kbmMW/MemTable) that do not clean up, then I would be interested in getting that.
It could also be that MadExcept is building its trace a bit to early in the shutdown phase.
Found the issue! The leak occurs when you call kbmmwshutdown before you terminate you application.
procedure TForm25.FormClose(Sender: TObject; var Action: TCloseAction);
begin
kbmmwshutdown; //comment me to prevent leak
end;