View unanswered posts | View active topics It is currently March 31st, 2017, 11:21 am



Reply to topic  [ 6 posts ] 
 TBBMM holding onto memory. 
Author Message

Joined: August 11th, 2010, 11:40 am
Posts: 3
Post TBBMM holding onto memory.
Hi

Although the speed of TBBMM is fantastic it seems to keep using memory and doesn't return much to the OS which we naturally thought was a fragmentation issue, however this simple code under a button in a default Delphi 2010 project;

Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  ObjList: TObjectList;
  i: integer;
begin
  ObjList := TObjectList.Create;
  for i := 1 to 10000000 do
  begin
    ObjList.Add(TObject.Create);
  end;
  Sleep(2000);
  FreeAndNil(ObjList);
end;


Yields surprising results in Memory (Private Working Set);

TBBMM: 1.7MB -> 200MB -> 160MB
FastMM: 1.6MB -> 197MB -> 4MB

I can't help think that something is wrong somewhere. In our real world application using TBBMM we just eat memory until it explodes, whereas FastMM is way slower but doesn't get anywhere near the 4GB limit for Win 32 bit apps (Large Address Aware).

Zach Saw mentioned on his blog site that the Windows default memory manager might be a better bet, any ideas how to hook that up in Delphi?

Thanks,
Bruce


August 11th, 2010, 12:05 pm
Profile
Site Admin

Joined: July 4th, 2008, 2:56 pm
Posts: 226
Post Re: TBBMM holding onto memory.
Latest version of Intel's TBB has already fixed it. I just haven't had time to recompile the new version.


August 11th, 2010, 8:37 pm
Profile
Site Admin

Joined: July 4th, 2008, 2:56 pm
Posts: 226
Post Re: TBBMM holding onto memory.
Let me explain the above a bit more.
It's not a bug - it's by-design.
The version of TBB that's on my website is linked to an older version of TBB which does not release memory to the OS.
It will however be reused when you allocate memory again.
So you could try that loop over and over and the memory wouldn't grow at all / by much.
This behavior is well documented in TBB's forums.
New version of TBB has changed this though and memory will be returned.


August 17th, 2010, 12:03 am
Profile

Joined: August 11th, 2010, 11:40 am
Posts: 3
Post Re: TBBMM holding onto memory.
Hi Zach

I was aware that TBBMM or atleast that version held onto some memory, however I was under the impression it would release large blocks back to the OS (I stand corrected). I can also see if it did that if the memory was badly fragmented enough that there would be no large blocks to hand back and yes I should have noted in my orginal post that on the n+1 run it doesn't use any more memory (well a little). It's cool that the new version fixes this problem, although it might not be much of a problem in practice as the 4GB or whatever would be paged out, depends if the OS wants to panic about it or not (with regard other apps trying to get memory).

On another note, do you know of any good tools that can be compiled in or externel to the app that can look as what is actually allocated by the app and where, (I know FastMM has a memory map facility) and even the type of the allocation? I ask as it would be nice to see the level of fragmentation and the type of object that was causing it to be fragmented, thus enabling one to maybe change that object allocation to a pool or something preallocated.

Thanks again for you work,
Bruce


August 17th, 2010, 1:01 pm
Profile
Site Admin

Joined: July 4th, 2008, 2:56 pm
Posts: 226
Post Re: TBBMM holding onto memory.
No I don't unfortunately.


August 17th, 2010, 4:56 pm
Profile

Joined: September 8th, 2010, 9:20 pm
Posts: 6
Post Re: TBBMM holding onto memory.
bruce wrote:
On another note, do you know of any good tools that can be compiled in or externel to the app that can look as what is actually allocated by the app and where, (I know FastMM has a memory map facility)
Bruce


Hi,

for this purpose there is something what I did : Google for "ANN: HpW Memory Monitor using FastMM4" (limited) :) or
get the "Memory Validater"... :roll:

Hp


September 8th, 2010, 9:26 pm
Profile
Display posts from previous:  Sort by  
Reply to topic   [ 6 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.