View unanswered posts | View active topics It is currently September 24th, 2017, 10:42 am



Reply to topic  [ 5 posts ] 
 Using MM with Delphi 2009 
Author Message

Joined: December 21st, 2008, 6:44 am
Posts: 3
Post Using MM with Delphi 2009
Google led me to this site and I quickly downloaded the MM so I could test it, assuming that what goes for the RAD should also go for the Pro version of D2009. Although being an fairly experienced Delphi programmer I haven't dwelled much over MM issues in multi-CPU-environments; I need some help here.

1. Installation is done by replacing the two DLL's in the bin-directory. Correct?
2. What do I do when distributing my applications? Delphi applications are normally contained in one exe and need not rely much on DLL's. Shall I now include the MM-DLL's and register them at the host-system?
3. I saw this test algorithm

Code:
DWORD WINAPI threadExecute(LPVOID obj)
{
    for (int i=0; i<10000000; i++)
    {
        char* test = new char[100];
        delete[] test;
    }
    return 0;
}


... although understanding most of it I'm unsure on how to reproduce the test in D2009. Initially I would try this but the words "WINAPI" (which I don't know what means in the C++ context) and "Thread" makes me believe that there's more to it. Should the tests be run in threads (a.k.a. not the main thread)? If so, how?

Scenario: Console application:

Code:
function ThreadExecute(Sender: TObject): boolean;
var
  i: integer;
  Buffer: pointer;
begin
  result := true;
  for i := 0 to 10000000 - 1 do
  begin
    GetMem(Buffer,100);
    FreeMem(Buffer);
  end;
end;

var
  TickStart: cardinal;
begin
  TickStart := GetTickCount;
  ThreadExecute(nil);
  writeln(format('%d ms',[GetTickCount - TickStart]));
end.


December 21st, 2008, 7:11 am
Profile

Joined: December 21st, 2008, 6:44 am
Posts: 3
Post Using MM with Delphi 2009
I ran the above mentioned test on my Lenovo T43 (2 GHz mobile) and got the results: Before: 656ms, after 547ms - an improvement of some 16%


December 21st, 2008, 7:23 am
Profile
Site Admin

Joined: July 4th, 2008, 2:56 pm
Posts: 226
Post Re: Using MM with Delphi 2009
The basic idea is to run multiple threads which simply does allocation and free of certain size on the heap. In Delphi, it'd be easier to derive from TThread and spawn multiple threads. TBBMM really shines when it is used in multiple threads.


December 22nd, 2008, 11:06 pm
Profile
Site Admin

Joined: July 4th, 2008, 2:56 pm
Posts: 226
Post Re: Using MM with Delphi 2009
Oh and yes, you'll have to include ShareMM in your uses list. You'll have to distribute borlndmm.dll and tbbmm.dll along with your executable. I haven't found a way to make it into a .lib file which can be built statically into an executable (Borland C++ Builder's lack of compliance to the latest standards is the problem - it simply wouldn't compile TBBMM).


December 22nd, 2008, 11:09 pm
Profile

Joined: December 21st, 2008, 6:44 am
Posts: 3
Post Re: Using MM with Delphi 2009
Thanks. I'll continue experimenting with the MM. Happy new Year from Denmark.


December 28th, 2008, 8:01 am
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 5 posts ] 

Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
cron
Powered by phpBB.