Question:
why the exe file in C occupies more memory than compared to its source file?
deeps
2009-07-17 20:37:01 UTC
suppose a sourc file occupies 68 bytes ,after execution the exe file fills 625 bytes of memory space?..why this happens?...
Five answers:
just "JR"
2009-07-17 23:50:02 UTC
Although your source file may be small, it will have to include some standard functions (that are not part of your source, but are included).

If you use an input() function, your code may be one line, but to execute the "input", the compiler adds all the bits and pieces to allow that "input" to work.
Ratchetr
2009-07-17 20:55:51 UTC
>> suppose a sourc file occupies 68 bytes

Then you haven't commented your souce code well enough.



>>after execution the exe file fills 625 bytes of memory space

That's amazingly small. You must not be using a M$ compiler ;-)



An exe file will always have a header that takes a few hundred bytes. Most languages have startup code that runs before the code you write, as well as run time libraries that might be brought in. These can increase the size of the exe considerably (a few hundred K isn't uncommon in the MS$ world).

This is mostly a fixed size overhead. As the size of your code increases exe size shouldn't increase proportionaly. If you write a couple million bytes of (commented!!!) source code, your exe should still be well under a meg (in most cases).



Oh, and make sure you're doing a 'release' build not a debug build. Debug builds can get really big.
fivetomins
2009-07-17 20:48:00 UTC
Because the *.exe file is an executable image, not just a file that containts a bunch of ASCII/UTF characters like your source file is/does. An executable image contains machine level instructions that have been "converted" (ergo compiled and linked) from your source, ergo lots of 1s and 0s that the CPU can understand. Contained in this image is a bunch of code that you didn't write but that gets bundled into whatever you DID write in order to perform whatever tasks your source attempts to perform, be it computations, I/O, memory management, etc.
2009-07-17 20:42:46 UTC
Because exe files are larger than the source they come from. 3.2 + 2.3 needs a lot of code to do that simple "+" that's only 1 byte.
zachery
2017-01-19 15:44:53 UTC
some unfastened utilities to do disassembly exist. some for assembly to C exist. in spite of the undeniable fact that, they gained't get better variable names, strucutre names, comments and different declarations in any way different than the convention of the decompiler/disassembler. So, what you will get would be incredibly unusual finding code, with no longer something wide-unfold in it. i've got seen programmers attempt and pull this trick with there very own code and nevertheless no longer recreate it o.k.. the positioning under has a type of such techniques, yet once I have been you, i could basically start up over. it incredibly is going to likely be extra basic and probable strengthen your expertise better than disassembling it may any way. EDIT -- there is one glimmer of desire that would enable you to out. you're saying which you "overwrite" the document? On some medium, including floppy or puzzlingpersistent, you will have the skill to apply a records retrieval application to hit upon the magnetic remanants of the document's photograph. basically by using fact the document is truncated, overwritten as quickly as or "deleted" would not propose that that's bodily long gone, it basically won't be able to be got here upon and examine by using the computing device's established techniques. attempt finding for a unfastened demo of the appliance. I desire you success.


This content was originally posted on Y! Answers, a Q&A website that shut down in 2021.
Loading...