Subject Re: [IBO] To use TIB_ as parameter DLL, need to use ShareMem or SimpleShareMem in uses clause?
Author hamacker
Yes, it´s the same when I use ClientDataset, that always in threads. Load and Unload plugin too fast it´s a risk.

Note my remark:
  LibHandle := SafeLoadLibrary(sArquivo);
    if LibHandle = 0 then
      Application.MessageBox(sArquivo,Pchar('Erro ao carregar ['+sModulo+'] :'));
    @ModuloInfo:=GetProcAddress(LibHandle, 'ModuloInfo');
    while not bOK do
      //Sleep(500);  <--- for debug

In the past I used Sleep(x) to workaround AVs with timer or thread troubles, now I doing using 'while not FreeLibrary' and I dont need Sleep(x) anymore. But sometimes when AVs appear like a ghost :(,  I debug unremarking Sleed(x) to see if my unload method still effective. One warning in this process is DON´T LOAD DLL RECURSIVELY.

Some guys recommend to use .bpl insted dll, but I don´t know how.

2015-02-04 10:10 GMT-02:00 Geoff Worboys geoff@... [IBObjects] <>:

AVs are always evil surprises. :-(

One thing to watch out for is the timing of your library
release. IBObjects does a number of things based on timer,
and the total release many Windows resources is not as
predictable as it could be. You may need to delay the
release of your DLL.

Note that you can also dynamically load and unload Delphi
runtime packages (see LoadPackage and UnloadPackage functions).
I do this in one my applications to provide a sort of plug-in
facility. (This application is still in Delphi6, I am in the
process of trying to upgrade, but it's a big application.)
Using this system I am sharing TIB_Connection and pretty much
everything other sort of component without problems. I do
the release in the application OnIdle processing by checking
reference counts on the dynamically loaded packages. (I
can't remember why I first did that, the code was written 15
years ago, but I do remember having trouble getting them to
release cleanly.)