Can't get the helloworld process's memory usage below 128KB. Seems that I should be able to do it in a lot less. Any ideas?
.486
.MODEL flat, stdcall
OPTION CASEMAP:NONE
Include include/windows.inc
Include include/kernel32.inc
Include include/masm32.inc
IncludeLib lib/kernel32.lib
IncludeLib lib/masm32.lib
.data
HelloMsg DB "Hello World", 0 ;*
.data?
buffer DB ?
.code
Start:
invoke StdOut, addr HelloMsg ;*
invoke StdIn, addr buffer, 1
invoke ExitProcess, 0 ;*
End Start
Err, I don't know, but maybe there is some "minimum"
Maybe the windows memory manager allocates at least 128kb (for user-level processes)
I think I read somewhere that the min size of a process is 4KB? Could be wrong, it's hard to find info on it
I actually get Mem Usage reported as around 514K-544K, depending on how I start the app..
But, if you minimize the console window then usage drops down to 48K-52K (and stays there even when restored.)
So, a large amount of the usage probably comes from associated GUI objects.
It's unlikely you could get a process to run in 4K, but it'll be 4K per section, and probably a minimum of 4 sections for actual running, so it'll be at least 16K just for the process image itself; then you have thread data, window info, various buffers, and many other things the OS handles for you..
The System Idle Process apparently requires 28K, so that might be the minimum.
.586
.model flat, stdcall
option casemap:none
include windows.inc
include kernel32.inc
includelib kernel32.lib
.const
hello db "Hello World!",13,10
.data?
hStdIn HANDLE ?
hStdOut HANDLE ?
nIOBytes DWORD ?
biff DWORD ?
.code
start:
invoke GetStdHandle, STD_INPUT_HANDLE
mov hStdIn,eax
invoke GetStdHandle, STD_OUTPUT_HANDLE
mov hStdOut,eax
invoke WriteFile, hStdOut,ADDR hello,SIZEOF hello,ADDR nIOBytes,NULL
invoke ReadFile, hStdIn,ADDR biff,1,ADDR nIOBytes,NULL
invoke ExitProcess, NULL
end start
Interesting, I still get 128KB using your code, minimized or not.
Windows Vista.
Quote from: Tedd on July 25, 2008, 06:36:54 PM
I actually get Mem Usage reported as around 514K-544K, depending on how I start the app..
But, if you minimize the console window then usage drops down to 48K-52K (and stays there even when restored.)
688, then 116-120 on XP SP2. I fumbled with .stack but no effect.
Tedd's code (except for having to add '\masm32\include\' (you slackarse) :P) starts at ~450k, then minimise/restore drops to 52k.
But working set, from procexp, is over 5meg - too many dll's loaded ??
I know that task manager calculates the memory usage in a strange way in that as yoyu call a system DLL like common dialogs the memory usage jumps up and stays up.
It may be worth creating a test piece that has SleepEx set to a large number and nothing else to see just how small you can get the system memory usage, this will give you some idea of how much overhead the system imposes when it starts an executable file.
Every program gets kernel32 loaded, since that's what loads the program, but kernel32 uses ntdll.
I got the same numbers as I did before with a program that consisted of "jmp $"
Looks like Vista just likes eating memory then (128K is nothing compared with everything else it does) ::)
Quote from: sinsi on July 26, 2008, 08:19:13 AM
Tedd's code (except for having to add '\masm32\include\' (you slackarse) :P)...
It's because I've got my environment set up correctly :P So there's no need to specify where the .inc and .lib files are unless they're not in the defualt folders.
(Add "/IC:\masm32\include" into the args for ml.exe, and "/LIBPATH:C:\masm32\lib" for link -- then you too can be lazy arse :toothy)
Quote from: hutch-- on July 26, 2008, 08:42:20 AM
I know that task manager calculates the memory usage in a strange way in that as yoyu call a system DLL like common dialogs the memory usage jumps up and stays up.
It may be worth creating a test piece that has SleepEx set to a large number and nothing else to see just how small you can get the system memory usage, this will give you some idea of how much overhead the system imposes when it starts an executable file.
I just tried just SleepEx and got it down to like 132kb memory usage. I also disassembled the "Hello World!" code and this is the output: http://bunnyboi.pastebin.com/m599cdcc5 and the code I used is here: http://bunnyboi.pastebin.com/m31aca6e6
I'm not sure why its disassembles like that. I wouldn't expect any NOP's in the code.