Painfully slow startup

Jay Krell jay.krell at
Thu Sep 14 08:37:54 CEST 2000

    int main() { LoadLibraryA("winmm"); return 0; }
    int main() { LoadLibraryA("winmm"); Sleep(INFINITE); return 0; }

will both result in winmm being paged out eventually, and probably at about
the same rate. The only way to keep it paged in is to call into it, and that
Will waste time (cpu cycles). And your calls won't necessarily hit the same
pages as loading it hits. You could Free/Load in a loop, but that Will waste
time too. You could Sleep/Free/Load in a loop but you won't win -- if you
don't sleep enough you end up busy waiting, if you sleep too long it'll get
paged out and then take time to page back in. Just keeping another
process/thread around will slow down the scheduler too.

 - Jay

-----Original Message-----
From: David Bolen <db3l at>
Newsgroups: comp.lang.python
To: python-list at <python-list at>
Date: Wednesday, September 13, 2000 6:51 PM
Subject: Re: Painfully slow startup

>"Jay Krell" <jay.krell at> writes:
>> No one said if it was paging in winmm or some per process startup it does
>> (which could also involve cached pageins).
>> To load winmm you can simply do
>>     rundll32 winmm,foo
>> at a command line, though it will put up an error.
>> The minimal C/C++ program:
>>     #include "windows.h"
>>     int main() { LoadLibraryA("winmm"); return 0; }
>I don't think you'd want to return from main though right?  If the
>application exits, Windows would unload the library if it was only
>that app using it, and while it might be lazy about reclaiming the
>memory, it could get reclaimed at any time.  So if you really wanted
>to make sure the winmm paging wasn't an issue you'd need to leave some
>application running that used it.
>Heck, I guess an extra copy of python in the background would serve
>just fine, not to mention probably speeding up the loading of the
>python dll at the same time since it would also be in memory.
>-- David

More information about the Python-list mailing list