Recent

Author Topic: borland delphi uses borlndmm.dll, whats for lazarus?  (Read 20475 times)

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
« Last Edit: November 19, 2010, 04:19:07 am by xenablaise »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8834
  • Programming + Glam Metal + Tae Kwon Do = Me

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: borland delphi uses borlndmm.dll, whats for lazarus?
« Reply #2 on: November 19, 2010, 02:35:06 pm »
hi

I'm pointing a .dll, why are you pointing to me "how to create your own memory manager"

whats the difference of this two?
thanks :D

ivan17

  • Full Member
  • ***
  • Posts: 173
Re: borland delphi uses borlndmm.dll, whats for lazarus?
« Reply #3 on: November 19, 2010, 02:46:53 pm »
well you are a bit unclear on what you need.  anyway you don't need a shared memory manager to use strings or entire classes from dll/so. the trick is to have exe and dll use the same memory manager (the same one, not the identical copy) and you're good.

for details, search the net for ExportClassFPC.zip if you need an example.

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: borland delphi uses borlndmm.dll, whats for lazarus?
« Reply #4 on: November 19, 2010, 03:00:29 pm »
Ok;
This is I understand;
if I use
getmem, new, allocmem, this is from the class? and the class gets from borlndmm.dll (if talking about delphi).

and if talking about lazarus?, getmem, new, allocmem is from the lazarus class also, on which memory are shared from the class.

If I use the "unit cmem" therefore I am using my own memory manager and not from the class.

Correct me if I'm wrong with that, please.

Quote
the trick is to have exe and dll use the same memory manager (the same one, not the identical copy)

BUT, I am using an external .dll on which the .dll is from another programmer that I test.
I am using the .dll to get an important function from it, then attached to my code.
And that sounds exe and dll do not use same memory, even if I use the "unit cmem". ?


Thanks :D

Leledumbo

  • Hero Member
  • *****
  • Posts: 8834
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: borland delphi uses borlndmm.dll, whats for lazarus?
« Reply #5 on: November 19, 2010, 03:04:27 pm »
Quote
I'm pointing a .dll, why are you pointing to me "how to create your own memory manager"
whats the difference of this two?
The .dll you're pointing is a replacement for Delphi's default memory manager, I'm showing that you can do that to FPC's memory manager as well. Of course you can't use that dll (yet) for FPC, and even if you can, it would be limited to i386-win32 only (unless you want to write A LOT of platform specific assembly for all supported platforms).
Quote
if I use
getmem, new, allocmem, this is from the class? and the class gets from borlndmm.dll (if talking about delphi).

and if talking about lazarus?, getmem, new, allocmem is from the lazarus class also, on which memory are shared from the class.
Did you mean if you use those functions, they are from standard libraries (either dll or statically linked)? Yes
Quote
If I use the "unit cmem" therefore I am using my own memory manager and not from the class.
No, you are using C memory manager. You can create your own, cmem is provided as an example for those who want to create their own.
Quote
BUT, I am using an external .dll on which the .dll is from another programmer that I test.
I am using the .dll to get an important function from it, then attached to my code.
And that sounds exe and dll do not use same memory, even if I use the "unit cmem". ?
It depends. Delphi normally has its standard libraries living in a dll, while FPC duplicates it for each dll and exe. This is due to the high level construct that needs initialization and can't be passed across executable boundaries (ansi- and wide-strings, for example) because they're managed by the rtl. Delphi dll AFAIK uses some dirty tricks to allow these data types to be passed, but only between Delphi (and perhaps C++ Builder) programs.
« Last Edit: November 19, 2010, 03:23:28 pm by Leledumbo »

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: borland delphi uses borlndmm.dll, whats for lazarus?
« Reply #6 on: November 19, 2010, 03:58:49 pm »
Ok;
in short;

I'm using getmem, new, allocmem, actually using allocmem to allocate data in memorystream.

like this;
type
pmyrec = ^myrec;
myrec = packed record
id:integer;
name:string;
end;
var thisrec:pmyrec;
...
while not dataset.eOF do begin
thisrec:=allocmem(sizeof(thisrec)); //allocates the memory
thisrec^.id:=1;
thisrec^.name:='somestring';
memstream.writebuffer(thisrec,sizeof(thisrec));
end;


There are hundred thousands of record I've saved in TmemoryStream.

During read time, from 0 to the LAST record sequentially!?  it counts 6 seconds.

Do you think if I use my own memory manager will improve the speed reading each record sequentially?


Thanks

Leledumbo

  • Hero Member
  • *****
  • Posts: 8834
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: borland delphi uses borlndmm.dll, whats for lazarus?
« Reply #7 on: November 20, 2010, 03:18:14 am »
It might, or might not. There are a lot of things to consider when finding the bottleneck of our application.

You said the read time is slow, but is there any memory allocation related things in reading items? When adding, there might be (reallocation to make the space bigger, for instance), but nothing when reading. Next, how exactly do you read it? Some people read one item then update the control showing these items. In this case, the bottleneck probably lies in the control, since the programmer forgot to call BeginUpdate-EndUpdate pair to postpone drawing.

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: borland delphi uses borlndmm.dll, whats for lazarus?
« Reply #8 on: November 20, 2010, 04:08:40 am »
Quote
There are a lot of things to consider when finding the bottleneck of our application.

Yes the bottleneck is at the function from an external .dll I'm using.
The function uses array of bytes with the size of 600 bytes that  sequentially scans/compare every [blobfield] in the whole table as a [string].

Quote
It might, or might not

But most of the time what is the near result? if using own memory management unit?

Leledumbo

  • Hero Member
  • *****
  • Posts: 8834
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: borland delphi uses borlndmm.dll, whats for lazarus?
« Reply #9 on: November 20, 2010, 07:18:31 am »
Quote
But most of the time what is the near result? if using own memory management unit?
Depending on how the memory manager is implemented. C memory manager implemented by cmem unit is faster, but allocates more memory than FPC's own.

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: borland delphi uses borlndmm.dll, whats for lazarus?
« Reply #10 on: November 20, 2010, 09:57:27 am »
Thank you :D

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 12572
  • FPC developer.
Re: borland delphi uses borlndmm.dll, whats for lazarus?
« Reply #11 on: November 20, 2010, 10:21:46 am »
Quote
But most of the time what is the near result? if using own memory management unit?
Depending on how the memory manager is implemented. C memory manager implemented by cmem unit is faster, but allocates more memory than FPC's own.

Isn't that 2.2.x based experience? 2.4.x has a new mm

xenblaise

  • Sr. Member
  • ****
  • Posts: 358
Re: borland delphi uses borlndmm.dll, whats for lazarus?
« Reply #12 on: November 20, 2010, 12:22:14 pm »
Quote
Isn't that 2.2.x based experience? 2.4.x has a new mm

Oh, you mean its not Ok? Im using lazarus-0.9.28.2-fpc-2.2.4-win32
So, shall I upgrade my fpc [only]? and Yes if thats the case.


Thanks

Leledumbo

  • Hero Member
  • *****
  • Posts: 8834
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: borland delphi uses borlndmm.dll, whats for lazarus?
« Reply #13 on: November 21, 2010, 03:19:57 am »
Quote
Isn't that 2.2.x based experience? 2.4.x has a new mm
Oh, I didn't know that. How's the behavior in 2.4.X?

ivan17

  • Full Member
  • ***
  • Posts: 173
Re: borland delphi uses borlndmm.dll, whats for lazarus?
« Reply #14 on: November 21, 2010, 08:26:44 am »
while memory manager would probably not be crucial factor in performance, there are still ways to minimize its impact. for example:
Code: [Select]
if need-to-allocate-space-for-the-next-record then
  allocate-space-for-50
else
  use-one-of-remaining;
in there you simply need to keep two limit variables - one for the actual length of array/list, the other for allocated capacity.

 

TinyPortal © 2005-2018