flat assembler
Message board for the users of flat assembler.

Index > Windows > high memory usage

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
Adam Mrówka



Joined: 04 Jul 2006
Posts: 4
Location: poznan, poland
Adam Mrówka 21 Jul 2006, 20:52
why this code use 2 224 kb memory?

windows task manager uses less memory than this code

Code:

format PE GUI 4.0

include 'win32ax.inc'

message db 'Hello!',0

.code

        start:

               invoke  MessageBox,HWND_DESKTOP,message,'Message',MB_OK
               invoke  ShellAbout,HWND_DESKTOP,'mrowek still testing # Flat Assembler','Do you like it?',0
               jmp exit
        exit:
              invoke  ExitProcess,0
.end start
    
Post 21 Jul 2006, 20:52
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 22 Jul 2006, 08:40
Don't worry, it's because the "standard" memory figure includes shared DLLs and such. What you want to do is to get Process Explorer, then add the "private bytes" figure to the column, that shows the "real" memory use of your app.
Post 22 Jul 2006, 08:40
View user's profile Send private message Visit poster's website Reply with quote
Adam Mrówka



Joined: 04 Jul 2006
Posts: 4
Location: poznan, poland
Adam Mrówka 22 Jul 2006, 15:40
jeah, at least it use only 616 kb but how decrease amount of memory?

should i use Heap instruction to reduce memory usage?
Post 22 Jul 2006, 15:40
View user's profile Send private message Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 22 Jul 2006, 16:07
616kb of private data? Not really a problem IMHO. Most of this is one-time overhead.

You can SetProcessWorkingSetSize(GetCurrentProcess(), -1,-1) - but that's sorta silly.

You really should just adjust your mindset wrt. windows programming Razz
Post 22 Jul 2006, 16:07
View user's profile Send private message Visit poster's website Reply with quote
Adam Mrówka



Joined: 04 Jul 2006
Posts: 4
Location: poznan, poland
Adam Mrówka 22 Jul 2006, 16:18
f0dder wrote:
You really should just adjust your mindset wrt. windows programming :P


almost beginner :D
Post 22 Jul 2006, 16:18
View user's profile Send private message Reply with quote
Borsuc



Joined: 29 Dec 2005
Posts: 2465
Location: Bucharest, Romania
Borsuc 22 Jul 2006, 16:33
f0dder wrote:
616kb of private data? Not really a problem IMHO. Most of this is one-time overhead.

Okay, I have to admit, the .exe loader and stuff like that in Windows is really blurred to me. What's that private data anyway, and why is it so "big" for a private data?

_________________
Previously known as The_Grey_Beast
Post 22 Jul 2006, 16:33
View user's profile Send private message Reply with quote
calpol2004



Joined: 16 Dec 2004
Posts: 110
calpol2004 24 Jul 2006, 13:50
the task manager is very unaccurate like one of the other users said (it includes all the dll's and resources n stuff the program is using or something like that Confused ), use something like process explorer to find out the real usage.
Post 24 Jul 2006, 13:50
View user's profile Send private message MSN Messenger Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 24 Jul 2006, 19:37
calpol2004 wrote:
the task manager is very unaccurate like one of the other users said (it includes all the dll's and resources n stuff the program is using or something like that Confused ), use something like process explorer to find out the real usage.


Actually... What it calls from DLLs is basically what i uses in the RAM and such. So if you're worried how much space it takes, you should rely on it. If you go by how much bytes it uses (excluding DLLs and all the things it includes) you're gonna expect it to run in really really poor conditions. Not like it really matters in a small project like the hello programs, but let's say you're coding something as power dependant as halo1 pc. imagin if they only recorded what the exe itself and it's DLLs took of the RAM not including what the OS requires with it... I could see it now... "Only 64 MB of ram needed." Then when the OS takes the other 64 that dosn't exist and the computer crashes, you got a major complaint. So i really don't see the point in getting what the EXE alone uses. One would think, anyway, that the EXE would only use the amount of space that the exe is if you don't include the space of the DLLs. At least that's what i think...
Post 24 Jul 2006, 19:37
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 25 Jul 2006, 11:12
kohlrak wrote:
calpol2004 wrote:
the task manager is very unaccurate like one of the other users said (it includes all the dll's and resources n stuff the program is using or something like that Confused ), use something like process explorer to find out the real usage.


Actually... What it calls from DLLs is basically what i uses in the RAM and such. So if you're worried how much space it takes, you should rely on it. If you go by how much bytes it uses (excluding DLLs and all the things it includes) you're gonna expect it to run in really really poor conditions. Not like it really matters in a small project like the hello programs, but let's say you're coding something as power dependant as halo1 pc. imagin if they only recorded what the exe itself and it's DLLs took of the RAM not including what the OS requires with it... I could see it now... "Only 64 MB of ram needed." Then when the OS takes the other 64 that dosn't exist and the computer crashes, you got a major complaint. So i really don't see the point in getting what the EXE alone uses. One would think, anyway, that the EXE would only use the amount of space that the exe is if you don't include the space of the DLLs. At least that's what i think...


Wrong again Smile

The reason you don't "count in DLLs" is that their code and data is shared between processes. What you need to do is get hold of Process Explorer (or use perfmon.msc which is included with 2k and XP), and look at the memory statistics counter called "Private Bytes".

This figure is the amount of, well, private bytes in your process. Memory not shared with other processes, memory that in low-memory situations will have to be paged out to disk and re-read, rather than discarded and re-read from .exe/.dll.

_________________
Image - carpe noctem
Post 25 Jul 2006, 11:12
View user's profile Send private message Visit poster's website Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 25 Jul 2006, 17:42
f0dder wrote:
kohlrak wrote:
calpol2004 wrote:
the task manager is very unaccurate like one of the other users said (it includes all the dll's and resources n stuff the program is using or something like that Confused ), use something like process explorer to find out the real usage.


Actually... What it calls from DLLs is basically what i uses in the RAM and such. So if you're worried how much space it takes, you should rely on it. If you go by how much bytes it uses (excluding DLLs and all the things it includes) you're gonna expect it to run in really really poor conditions. Not like it really matters in a small project like the hello programs, but let's say you're coding something as power dependant as halo1 pc. imagin if they only recorded what the exe itself and it's DLLs took of the RAM not including what the OS requires with it... I could see it now... "Only 64 MB of ram needed." Then when the OS takes the other 64 that dosn't exist and the computer crashes, you got a major complaint. So i really don't see the point in getting what the EXE alone uses. One would think, anyway, that the EXE would only use the amount of space that the exe is if you don't include the space of the DLLs. At least that's what i think...


Wrong again Smile

The reason you don't "count in DLLs" is that their code and data is shared between processes. What you need to do is get hold of Process Explorer (or use perfmon.msc which is included with 2k and XP), and look at the memory statistics counter called "Private Bytes".

This figure is the amount of, well, private bytes in your process. Memory not shared with other processes, memory that in low-memory situations will have to be paged out to disk and re-read, rather than discarded and re-read from .exe/.dll.


You make it as if everything not shared is paged to disk... This alone isn't true, last time i check. I was always told that information is only paged to disk when the programs with the highest priority at the time (the ones visible on the screen have second, first is the one on top, and third is the one who's not visible on the screen while the one with higher priority in the processes part of task manager gets higher than them. But i have a feelingthat which is in the parenthesis isn't 100% true but it's what i go on lol) are in the RAM and the paged programs go in order of lowest to highest priority.
Post 25 Jul 2006, 17:42
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 25 Jul 2006, 18:18
Quote:

You make it as if everything not shared is paged to disk... This alone isn't true, last time i check. I was always told that information is only paged to disk when the programs with the highest priority at the time (the ones visible on the screen have second, first is the one on top, and third is the one who's not visible on the screen while the one with higher priority in the processes part of task manager gets higher than them. But i have a feelingthat which is in the parenthesis isn't 100% true but it's what i go on lol) are in the RAM and the paged programs go in order of lowest to highest priority.

Well, paging only happens in low-memory situations of course. Windows is a bit aggressive at working-set trimming though, which can give some not so logical paging even if you don't have a low-low memory situation.

You might want to check out "inside windows 2000" (or the later XP edition), it has some very good descriptions of what's going on inside windows, so you won't have to rely on incorrect information or your own flawed assumptions ^_^
Post 25 Jul 2006, 18:18
View user's profile Send private message Visit poster's website Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 25 Jul 2006, 18:46
Got a link to bookmark? lol Or is it in the useful links at the top of the forums? lol
Post 25 Jul 2006, 18:46
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 26 Jul 2006, 08:26
It's a book, and available in ebook (CHM) form as well.
Post 26 Jul 2006, 08:26
View user's profile Send private message Visit poster's website Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 26 Jul 2006, 19:47
Where does the CHM work?
Post 26 Jul 2006, 19:47
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 27 Jul 2006, 10:20
kohlrak wrote:
Where does the CHM work?

Rephrase, don't understand you.

_________________
Image - carpe noctem
Post 27 Jul 2006, 10:20
View user's profile Send private message Visit poster's website Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi 27 Jul 2006, 14:27
kohlrak wrote:
Where does the CHM work?


CHM is help-file like format, and I believe windows supports it natively.

_________________
When We Ride On Our Enemies
support reverse smileys |:
Post 27 Jul 2006, 14:27
View user's profile Send private message MSN Messenger Reply with quote
kohlrak



Joined: 21 Jul 2006
Posts: 1421
Location: Uncle Sam's Pad
kohlrak 27 Jul 2006, 20:28
i mean "live" not work. I musta been in some kinda hurry when typign ti. I know their format, there are lots of them included with fasm... o.O
Post 27 Jul 2006, 20:28
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger MSN Messenger Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi 27 Jul 2006, 20:40
kohlrak wrote:
i mean "live" not work. I musta been in some kinda hurry when typign ti. I know their format, there are lots of them included with fasm... o.O


Confused Question Question Question
Now I'm confused.

_________________
When We Ride On Our Enemies
support reverse smileys |:
Post 27 Jul 2006, 20:40
View user's profile Send private message MSN Messenger Reply with quote
f0dder



Joined: 19 Feb 2004
Posts: 3175
Location: Denmark
f0dder 28 Jul 2006, 11:26
He probably means where he can leech a warez copy of inwin2k.chm... I bought the book Smile
Post 28 Jul 2006, 11:26
View user's profile Send private message Visit poster's website Reply with quote
okasvi



Joined: 18 Aug 2005
Posts: 382
Location: Finland
okasvi 28 Jul 2006, 12:04
f0dder wrote:
He probably means where he can leech a warez copy of inwin2k.chm... I bought the book Smile


oic, should have guessed Razz

_________________
When We Ride On Our Enemies
support reverse smileys |:
Post 28 Jul 2006, 12:04
View user's profile Send private message MSN Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.