www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Where is the runtime memory overhead from?

reply "Nick Sabalausky" <SeeWebsiteToContactMe semitwist.com> writes:
Consider this program:

// blank.d
void main() {
    while(true) {} // Poor man's sleep ;)
}

dmd blank.d
On WinXP 32-bit DMD 2.058, if I run that, task manager tells me it's using 8816k of memory. *Note: I'm not complaining.* I just wanted to ask if anyone knows what that overhead is primarily from? Just from druntime/phobos being statically linked? OS process overhead? Some DLLs that are implicitly used? (But I assume DLLs aren't counted in that memory usage figure...) Etc... I don't think it's from the raw exe file itself being loaded into mem, because that's only 143k. As a frame of reference, if I change "true" to "1" and compile with DMC (instead of DMD), then it only uses 1265k ram. (The exe file is smaller too, but *that* I'm sure is just because of phobos/druntime being statically linked.) The reason I'm asking is I'm making a few minor edits to my "Have Your Efficiency, and Flexibility Too" article, and I'm tempted to breifly point out that the 10% decrease in memory usage with the "handcrafted version" is better than it sounds because most of that 10MB ram is just overhead. But saying that D programs have 8-9MB runtime overhead probably sounds very bad, so I'm not sure I want to do it if I can't provide a (breif) "Don't worry! Because..." (Although I may still just skip the whole mention altogether and just leave it at "10% decrease in memory - and now on to the next section" and not even worry about it. Whatever. In any case, I am at least curious.)
Apr 12 2012
parent reply "Nick Sabalausky" <SeeWebsiteToContactMe semitwist.com> writes:
"Nick Sabalausky" <SeeWebsiteToContactMe semitwist.com> wrote in message 
news:jm63tu$27uq$1 digitalmars.com...
 The reason I'm asking is[...]
Actually, that junk doesn't matter, I found a way to put it without getting that detailed and derailed. But I am curious what the memory overhead is from. My guess would be that it's just memory used by misc parts of the statically-linked phobos/druntime, but I don't actually know.
Apr 12 2012
parent Manfred Nowak <svv1999 hotmail.com> writes:
Nick Sabalausky wrote:

 But I am curious what the memory overhead is from. My guess
Your guess is wrong. process monitor from sysinternals reveals, that several windows system dll's are loaded under the process number belonging to that loop. -manfred
Apr 12 2012