Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

FastShareMem - System resources exceeded

Status
Not open for further replies.

Griffyn

Programmer
Jul 11, 2002
1,077
AU
This one took me a lot of testing to work out. I haven't written up a test project to confirm 100% exactly what circumstances causes the issue, but since changing from FastShareMem to FastMM4, my problems have stopped.

The project was a service application that dynamically loaded a number of DLLs (written by myself), called a procedure within, and then freed the DLL. Code from the project:

Code:
[b]type[/b]
  TExternalCheck = [b]function[/b](ALocalConnection, ANexusConnection: TADOConnection; ATranNum,
    AParam1, AParam2, AParam3, AParam4, AParam5, 
    AParam6, AParam7, AParam8, AParam9: String): Boolean; stdcall;
[b]var[/b]
  Handle : THandle;
  ExternalCheck : TExternalCheck;
  DLLName : String;
[b]begin[/b]
  [navy][i]// ... snip - outer loop for all DLLs  ...
[/i][/navy]  Log([purple]5[/purple], [teal]'Loading library '[/teal] + DLLName);
  Handle := LoadLibrary(PChar(DLLName));
  [b]try[/b]
    [b]if[/b] Handle <> [purple]0[/purple] [b]then[/b]
    [b]begin[/b]
      @ExternalCheck := GetProcAddress(Handle, [teal]'CheckDocument'[/teal]);
      [b]if[/b] @ExternalCheck <> [b]nil[/b] [b]then[/b]
        ExternalCheck(LocalConnection, GetNexusConnection,
          ATranNum, FieldByName([teal]'Param1'[/teal]).AsString,
          FieldByName([teal]'Param2'[/teal]).AsString, FieldByName([teal]'Param3'[/teal]).AsString,
          FieldByName([teal]'Param4'[/teal]).AsString, FieldByName([teal]'Param5'[/teal]).AsString,
          FieldByName([teal]'Param6'[/teal]).AsString, FieldByName([teal]'Param7'[/teal]).AsString,
          FieldByName([teal]'Param8'[/teal]).AsString, FieldByName([teal]'Param9'[/teal]).AsString);
    [b]end[/b]
    [b]else[/b]
      LogFmt([purple]2[/purple], ATranNum, [teal]'Unable to load library %s'[/teal], [DLLName]);
  [b]finally[/b]
    Log([purple]5[/purple], [teal]'Unloading library '[/teal] + DLLName);
    FreeLibrary(Handle);
  [b]end[/b];

The service app and every DLL used FastShareMem as the first unit. Each DLL would use a TADOConnection passed as a parameter to create a new TADOQuery to look at data in a table. The TADOQuery was then freed. After about 1500 iterations, every attempt to open a TADOQuery either in a DLL or in the service application resulted in an exception "System resources exceeded". The OS (Windows 2000 Advanced Server) would need a reboot before things would work properly again. Task Manager was useless in trying to see which resouce, exactly, was being exceeded.

It took me ages to track down, and simply changing FastShareMem to FastMM4 fixed the issue instantly, without any other changes needed. The one exported procedure in each DLL has the same header.

I'm not sure why I was using FastShareMem for in the first place - it's the only project I've used it in.

What's it good for?
 
it was the next best thing BEFORE fastmm4.

[spin]

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
You used to require that unit if you were going to pass Pascal strings between your application and a DLL.
 
DjangMan, that was Sharemem (borland's DLL).
Fastsharemem could be compiled into the exe/dll without requiring the extra borlndmm.dll.

/Daddy

-----------------------------------------------------
What You See Is What You Get
Never underestimate tha powah of tha google!
 
Ah. You'd think the author of FastShareMem would be good enough to take down his website then.

Thanks guys.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top