Author | Message | Time |
---|---|---|
LordVader | Curious to oppinions, when I first create a basic window program with nothing but the window and icon loaded into it. The residual memory it's using when executed is fairly high 2000 K+. I know in asm you can stream line the windows.inc file include by removing un-needed items as one example to reduce over all load and exe size.. Wondering if there are basic known equivelants to that in C++ (best practices basically) for includes and compile settings. As well as ideas/theories on memory management in general on streamlining performance in applications when/where/method concepts.. | September 2, 2004, 3:23 PM |
Kp | From your description, you've configured the project very wrong. I have a nontrivial desktop management application with "Mem Usage" of 1844kb, and a VM size of 316kb. Check that you're actually optimizing the program, that you've stripped debug symbols, etc. Also, carefully pick which functions you call: some DLLs cause other DLLs to be loaded, so you might be dragging along a lot of unneeded baggage. | September 2, 2004, 4:09 PM |
LordVader | Yeah, i'm still learning the diff compile options.. thx for the input probably is debug switches in compile options.. | September 2, 2004, 11:27 PM |
Kp | [quote author=LordVader link=board=30;threadid=8536;start=0#msg78804 date=1094167632]Yeah, i'm still learning the diff compile options.. thx for the input probably is debug switches in compile options..[/quote] What compiler(s) are you using? The switches vary widely among the compilers. | September 2, 2004, 11:51 PM |
LordVader | Visual Studio v6 C++ | September 2, 2004, 11:56 PM |
LordVader | These are my project settings under the C/C++ tab: - General Maximise speed: [code] /nologo /ML /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"Release/Opbot.pch" /YX /Fo"Release/" [/code] Minimize size: [code] /nologo /ML /W3 /GX /O1 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /Fp"Release/Opbot.pch" /YX /Fo"Release/" [/code] - Code Generation Processor: Blend* Use Run Time Library: single-threaded* Calling Convention: _cdecl* Struct member alignment: 8 bytes* - Optomizations: Only_inline (for minimize size and maximize speed) With it set to auto use precompiled headers.. Under the link tab has various lib's included, and checked values are: Generate Debug info & Link incrementally. With project options: [code] kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:windows /incremental:yes /pdb:"Debug/Opbot.pdb" /debug /machine:I386 /out:"Debug/Opbot.exe" /pdbtype:sept [/code] | September 3, 2004, 12:08 AM |
Kp | Turn off incremental linking and rebuild. | September 3, 2004, 1:20 AM |
LordVader | Ahh Nice thx heh good bit smaller memory footprint and exe size now 41kb exe vs 61kb, and bout 500-800kb smaller in memory when first run.. good stuff | September 3, 2004, 1:34 AM |
LordVader | also using: [code] #ifdef NDEBUG #pragma optimize("gsy",on) #pragma comment(linker,"/RELEASE") #ifdef _MERGE_RDATA_ #pragma comment(linker,"/merge:.rdata=.data") #endif #pragma comment(linker,"/merge:.text=.data") #pragma comment(linker,"/merge:.reloc=.data") #pragma comment(linker,"/ignore:4078") #if _MSC_VER >= 1000 #pragma comment(linker,"/opt:nowin98") #endif #endif [/code] From AggressiveOptomize.h reduces memory footprint even more :) Just for reference, to other's using maximize speed decreases the memory footprint (of course), and minimize size can slightly reduce .exe size but at a cost of a higher memory footprint. *Edit fixed typo. | September 3, 2004, 1:37 AM |
St0rm.iD | I'm not an expert in this, but don't you want to use __fastcall? | September 3, 2004, 2:26 PM |
Kp | [quote author=$t0rm link=board=30;threadid=8536;start=0#msg78882 date=1094221592]I'm not an expert in this, but don't you want to use __fastcall?[/quote] Not necessarily. Consider this example:[code] void _fastcall foo(int x, int y) { bar(1, 3); hmm(7, 9); p(x); q(y); }[/code] __fastcall requests the parameters come in in registers, but if your function already has uses for all the stable registers, it'll end up spending instructions kicking the operands out onto the stack for longer storage until they're used, thereby making the code longer. My example doesn't quite follow this explanation, as I don't include anything to consume the other stable registers, but it illustrates the idea that if the parameter isn't used quickly, it might be better not to put it in a register. | September 3, 2004, 4:23 PM |
St0rm.iD | The optimizer will automatically __fastcall anything that would be best called as __fastcall, right? | September 4, 2004, 3:55 PM |
Kp | [quote author=$t0rm link=board=30;threadid=8536;start=0#msg79052 date=1094313349]The optimizer will automatically __fastcall anything that would be best called as __fastcall, right?[/quote] Not necessarily. It can't do that if the caller and callee are in different files (especially since one might be available only as object code, and therefore a huge pain for the compiler to modify). Whether it will automatically change them when it has the source to both depends heavily on the quality of your optimizer - I've never seen a decent Microsoft optimizer, so I can't say whether it would or not. | September 4, 2004, 5:09 PM |