News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

small memory footprint 32bit application

Started by dabur, March 27, 2007, 11:42:45 AM

Previous topic - Next topic

dabur

Hi All,

The subject says a lot what I'm looking for  :wink ...

After searching the internet for a "smallest exe" and stuff like that, I ran against competitors and real games for creating stuff in assembler, in the smallest windows 32bit exe's ever... amazing.

Even on this forum I'm finding topics of small exe's...    :U  but they all use <when running on windowsXP/2003> over 1.000 K memory.
(like the sample minimum.exe in the MASM directory)

Any suggestions for a small memory footprint "dummy" application?

Why?
I need a dummy process for an own made construction on a windows2003 server, where I have to preload 200 different userhives, to speedup the later logon for these users (yes, on a terminal server). We now use minimum.exe to keep that userhive loaded on the system (when closed it's automatically unloaded), but 200 times this small process is still using 400MB memory. Btw, this pre-fetching of user hives does work like we want to, and speeds up logon processing on our server (in some cases we have 2 to 3 interactive logons per second)!     :dance:

Greetings,
Dabur

PS: In my college days, I had courses assembler on the intel 8088 and the motorola 68000. Stuff you guys are doing on the x64/x86 platform is amazing and a lot different (read complex for me  :red )



hutch--

Hi dabur,

Welcome on board. A couple of things, you need to understand how the system calculates memory usage in relation to functions called using system DLLs.

While running a single instance of an app will show a particular memory usage by counting the size of the system DLLs being used, multiple instances use the same DLLs without reloading them so the increase in memory usage is not linear with the increase in running instances.

The things you can do when writing a specialised app of he type you have in mind is keep the code size small, call the minimum number of DLL functions and use the linker option to trim down the stack size for every instance of the app. Effectively what you must do is minimise the amount of work being done by each instance so that the total processor usage and memory usage do not slow the machine down any further than it needs to perform its normal tasks.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

dabur

Hutch, thanks for the reply. But I'm a sysem engineer, with some programming skills (pascal, VB 6, VB.NET), but not that "high level"... System Engineers are more in the scripting corner (WSH, VBS, KIX32, Batching, powershell  ).  :wink ..

I understand what you are pointing to. Indeed on Terminal Server the DLL's are shared between all users (thus a lot of memory is still available).
But looking for a dummy.exe which does nothing and uses nothing seems a big challange? We do find stuff like that for Linux OS's, but for windows nobody seemed to be in the scenario where I am at the moment.

I was kinda hoping someone would post some ASM 32bit code  :red


dabur

I've got help from Draakie (thanks!): http://www.masm32.com/board/index.php?topic=3673.0

tried it out: process started at 64K Memory and 64K Virtual Memory;  GREAT!

But later on, it started "leaking to 2.000 K" and using 50% cpu and finally crashed.

AppName: smallest.exe    AppVer: 0.0.0.0    ModName: unknown
ModVer: 0.0.0.0    Offset: 00000000

code used:

.386
.MODEL FLAT, STDCALL
OPTION CASEMAP:NONE
.CODE

start:
               push 0
               RET
END start

hutch--

dabur,

What you are not telling us is what the minimum exe is supposed to do. The code that Draakie has posted imediately exits when it is run. How are you trying to use it ?
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

Draakie

Erm - was'nt my post - merely pointed the gent towards what I thought
he was looking for - thus the shortcut to topic "SMALLEST PE". I ca'nt be
blamed for what he does with it  :lol Looks like he wants to authenticate
users by somehow piggy-backing on a dummy process executed on the
terminal server. [I 'am probably way-off though  ::)]
Does this code make me look bloated ? (wink)

PBrennick

All you need to do is write a program that contains an infinite loop and does nothing else. You could write an escape method using the keyboard. This would add to the code in terms of size but not in terms of memory usage which is what you are looking for. If you do not provide an escape function, you can always force the app down when you want to. I would use an escape function, though, involving a key combination that is not often used.

Paul
The GeneSys Project is available from:
The Repository or My crappy website

dsouza123


.386
.model flat, stdcall
option casemap:none

include    \masm32\include\kernel32.inc
includelib \masm32\lib\kernel32.lib

.code
start:
L0:
   push 15000
   call Sleep
   jmp L0

   push 0
   call ExitProcess
end start

dabur

Quote from: hutch-- on March 28, 2007, 12:58:53 PM
dabur,

What you are not telling us is what the minimum exe is supposed to do. The code that Draakie has posted imediately exits when it is run. How are you trying to use it ?

=> It has to keep running, yes like PBrennick is mentioning, waiting for a keyboard hit that is never to come.

=> The post of dsouza123 is in right direction!  :thumbu  Using 596K mem (virtual 180K) and not using cpu.. THANKS !!! :clap:

hutch--

If you manually set the stack memory usage in the linker options you will get the stack usage lower as well.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php