Which bpls should I redistribute?

delphi package - automated exception handling
Post Reply
frankmoritz
Posts: 6
Joined: Sun Jun 03, 2007 9:42 am

Which bpls should I redistribute?

Post by frankmoritz »

Hi,

which bpls should I redistribute with my software, if I use runtime packages with madExcept? I figured out that at least madBasic_.bpl, madDisAsm_.bpl and madExcept_.bpl are needed, but what about the other ones, for example the madExceptIde_.bpl or the madExceptWizard_.bpl?

Thanks and regards
Frank
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: Which bpls should I redistribute?

Post by madshi »

madBasic, madDisAsm and madExcept suffice. The others are only used within the IDE.

Alternatively, you can also disable the madExcept runtime packages and link the madExcept units into your EXE file. That works just fine, as well, even if you're using runtime packages for all the other packages. The only disadvantage is that if you do it like that, your BPLs cannot link to madExcept.
frankmoritz
Posts: 6
Joined: Sun Jun 03, 2007 9:42 am

Re: Which bpls should I redistribute?

Post by frankmoritz »

Hi,

thanks. If I enable madExcept in each bpl (because I load them dynamically using LoadPackage() and I would like to have some separation between the main program and the bpl plugins), is it usefull (or even possible?) to enable the leak checking for the bpl? Would you recommend it? I tried this and the "Filtering child leaks..." window is being displayed after UnloadPackage(), but then it takes a lot of time before displaying the results. I suppose that this is not a use case you would recommend and I should rather switch to Dlls to have a clear separation?

Regards
Frank
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: Which bpls should I redistribute?

Post by madshi »

For your packages, I would recommend activating madExcept but only attaching the function names and line numbers, but not link the madExcept source code into them. The madExcept instance running in your EXE file (or in the madExcept_.bpl) will hook into the RTL packages automatically and thus protect all your packages, as well. However, madExcept still needs access to the unit names and line numbers of your packages - at least if you want crash reports to cover your packages, as well, which I assume you do. You can achieve this goal by enabling madExcept for your project but just check the option "link in function name and line numbers", but keep the options "link in madExcept code" and "link in settings" unchecked. See here:

http://help.madshi.net/madExceptSettings.htm

Leak reporting is supposed to work just fine, but it's a feature that is mainly only intended to be used on your development PC or in your test lab. It's normally not recommended to do leak reporting on the customers' computers, because leak reporting slows things down a bit and consumes HUGE amounts of extra RAM. Same with the "instantly crash" feature. That's also intended for the dev PC, but not for end users.

Filtering child leaks can take some time. It basically checks which leaks may be "childen" of other leaks and then hides them. For example, if you leak some object "TFancyObject" and this object internally has some strings and other resources, then those are all child leaks. Hiding them can reduce the number of overall leaks reported to you a lot, but the filtering procedure costs time. How long is "a lot of time", though? It shouldn't be THAT long!

You can use the following API (exported by madExcept.pas) to disable child leak filtering, if you want:

Code: Select all

// Do you want child leaks to be filtered (can be very slow)?
procedure SetChildLeakFiltering (doFiltering: boolean);
frankmoritz
Posts: 6
Joined: Sun Jun 03, 2007 9:42 am

Re: Which bpls should I redistribute?

Post by frankmoritz »

Hi,

the duration of the leak checking is not really a problem. It just give me a hint for something probably not doing right.

If I disable the madExcept settings for the bpls, I loose the ability of plugin specific error reporting, for example the web server upload. I'd like to handle exceptions plugin specific to report them to the respective internal or external developers.

Please clarify the madExcept options using bpls. Should I uncheck "link in madExcept code" (and probably "link in madExcept settings") in the main program and in the bpl plugins?

One more question regarding the use of ShareMem.

I noticed some small memory leaks reported for strings. Do I have to use ShareMem (or SimpleShareMem?) in Bpls? What are the rules if I load Bpls and Dlls in an program? In doubt I currently use SimpleShareMem in all of them at the moment.

Regards
Frank
madshi
Site Admin
Posts: 10753
Joined: Sun Mar 21, 2004 5:25 pm

Re: Which bpls should I redistribute?

Post by madshi »

You can use "link in madExcept settings" for your BPLs, that's fine. If you do use the "madExcept_bpl", then you can also use "link in code". But if you don't want to use the madExcept_.bpl, then I would recommend not to link in the code into the BPLs, because otherwise all the madExcept code will be in every one of your BPLs, which seems very wasteful.

So basically I'd recommend either one of these 2 options:

1) Either disable madBasic_.bpl, madDisAsm_.bpl and madExcept_.bpl and activate "link in code" only in your EXE file. This way all the madExcept code will be linked into your EXE file, and will still cover all the BPLs without making the BPLs bigger. But you can't call any madExcept APIs in your BPLs this way.

2) Or use the mad*. bpls, in which case it's perfectly fine to also use "link in code" in your BPLs, and you can then also call the madExcept APIs in your BPL, if you want to.

ShareMem used to be needed when using DLLs. I don't think it was ever needed when using BPLs. I'm not 100% sure if you still need ShareMem if you do DLLs now. FastMM4 might already do the sharing internally, but I'm not really sure.
Post Reply