SRL Archive - FAQ

Memory Usage in Simba?


Sir R. M8gic1an

2011-02-17 06:33:54

Im developing some things for myself & MSI, and I was wondering how / if I can check how much memory is currently being used?

~RM

Wizzup?

2011-02-17 06:37:18

Task manager.

Flight

2011-02-17 07:01:15

I found two bits of code you might find useful, they're not mine but maybe you'll find what you're looking for

The include file (memcheck_laz.inc) contains the added features:
>
> procedure CheckHeap;
> procedure CheckHeap(const txt: ansistring);
> procedure CheckHeapWrtMemCnt(const txt: ansistring);
> procedure WriteGetMemCount(const txt: ansistring);
>
> function MemCheck_getmem_cnt: longint;
> function MemCheck_freemem_cnt: longint;
> function MemCheck_getmem_size: longint;
> function MemCheck_freemem_size: longint;
> function MemCheck_getmem8_size: longint;
> function MemCheck_freemem8_size: longint;
>
> You may want to change the longints to int64.


Program SmallApp;

function MessageBoxA(HWND: Cardinal; Msg,Title: pChar; Flags: Cardinal): Cardinal; stdcall; external 'User32.dll';
function SetProcessWorkingSetSize(hProcess: LongWord; dwMinimumWorkingSetSize, dwMaximumWorkingSetSize: LongWord): LongBool; stdcall; external 'kernel32.dll';
function GetCurrentProcess: LongWord; Stdcall; external 'kernel32.dll';
procedure Sleep(dwMilliseconds: LongWord); stdcall; external 'kernel32.dll';

begin
MessageBoxA(0,'Hello from a small app.','Small App',0);
SetProcessWorkingSetSize(GetCurrentProcess, $FFFFFFFF, $FFFFFFFF);
MessageBoxA(0,'Hello from a smaller app.','Small App',0);
SetProcessWorkingSetSize(GetCurrentProcess, $FFFFFFFF, $FFFFFFFF);
Sleep(30000);
end.


PS: I put them in quotes because they're not mine so I won't take credit for them.

Wizzup?

2011-02-17 07:05:42

By the way, these aren't in Simba. Might be useful for this.

Flight

2011-02-17 07:29:26

I figured they weren't in Simba, but if you had "memcheck_laz.inc" could you not just include it and call it from your script/program? It seems like that's a global Pascal include file.

Here's the "memcheck_laz.inc" include:
http://lazarus.sourcearchive.com/lines/0.9.26-3/memcheck__laz_8inc-source.html

Wizzup?

2011-02-17 07:37:39

From: Flight
I figured they weren't in Simba, but if you had "memcheck_laz.inc" could you not just include it and call it from your script/program? It seems like that's a global Pascal include file.

Here's the "memcheck_laz.inc" include:
http://lazarus.sourcearchive.com/lines/0.9.26-3/memcheck__laz_8inc-source.html


It doesn't work like that, sorry.

Sir R. M8gic1an

2011-02-18 05:29:20

Seems like I'll just follow intuition on what uses more memory, and any finds on this I'll report them to the other thread… and I guess there's a need to read up on Lazarus..

Cheers Flight & Wizzup

~RM