flat assembler
Message board for the users of flat assembler.

Index > Windows > memory usage

Author
Thread Post new topic Reply to topic
sleepsleep



Joined: 05 Oct 2006
Posts: 13045
Location: ˛                             ⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣⁣Posts: 0010456
sleepsleep 29 Apr 2007, 11:09
hi there,
is there a tool to check fasm assembled exe or dll memory usage?

any idea how to check if i forgot to close an opened handle? (they called it memory leak i guess)
Post 29 Apr 2007, 11:09
View user's profile Send private message Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 29 Apr 2007, 14:03
I don't know about memory leaks (as i'm pretty darn prone to them, which woudln't surprise me if AOL and such have such issues), but if you can save your memory to disk and hex edit the file (difficult way to do it, actually) or if you have any better methods, you could always leave a small variable in the function or section in question (a db variable saying "sleeepsleepcheck" or something like that) and search for that. That's usually what i would do if i had any programs that i wanted to claim as mine, since not many would probably go around hex editing every program that they like.
Post 29 Apr 2007, 14:03
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
LocoDelAssembly
Your code has a bug


Joined: 06 May 2005
Posts: 4624
Location: Argentina
LocoDelAssembly 29 Apr 2007, 15:38
Instead of calling directly to the API functions you can call your own funtions that first increments a counter and then call the desired function. The same with deallocating/closing functions but decrementing the counter instead. If counter is not zero on exit you have a leak.
Post 29 Apr 2007, 15:38
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 02 May 2007, 23:00
Using your own wrappers is a very good idea indeed - and if fasm supported conditional assembly, it would be even easier to do it decently :]

There's commercial tools that are pretty good (boundschecker...), but they tend to be pretty expensive.
Post 02 May 2007, 23:00
View user's profile Send private message Visit poster's website Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 02 May 2007, 23:09
Quote:
and if fasm supported conditional assembly, it would be even easier to do it decently

i am not sure what exactly you mean by "conditional assembly", but probably something like this?
Code:
if used malloc
malloc:
inc [alloc_count]
call [imported_malloc]
end if    
Post 02 May 2007, 23:09
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
vid
Verbosity in development


Joined: 05 Sep 2003
Posts: 7105
Location: Slovakia
vid 03 May 2007, 09:48
LocoDelAssembly wrote:
Instead of calling directly to the API functions you can call your own funtions that first increments a counter and then call the desired function. The same with deallocating/closing functions but decrementing the counter instead. If counter is not zero on exit you have a leak.

using similar approach you can also count allocated memory. Problem might be with reallocation.

pseudocode to count sum of allocated memory (which is not real usage btw...):
Code:
my_alloc(size):
  block=alloc(size+4)
  dword [block] = size;
  total_size += size;
  return block+4;

my_realloc(block, newsize):
  total_size -= dword [block-4]
  block=realloc(block-4, newsize+4);
  dword [block] = newsize;
  total_size += newsize;
  return block+4;

my_free(block);
  total_size -= dword [block-4]
  free(block-4)
    
Post 03 May 2007, 09:48
View user's profile Send private message Visit poster's website AIM Address MSN Messenger ICQ Number Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
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
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.