tags:

views:

131

answers:

3

I just noticed the memory usage of a simple win32 C based GUI application with single main window taking around 3 MB memory ( via Task Manager )

I used Dev-c++ and Mingw as compiler , and generated windows application via project wizard.

why that so ? is there any way to reduce it ?

A: 

Memory in task manager shows how much memory windows has allocated to your process. It in no way reflects how much memory is actually being used by your program. If you are using the Mingw that came with Dev-C++ then you might want to try getting the new version of Mingw. Dev-C++ has been abandoned for quite some time so the bundled compiler is quite out of date.

stonemetal
Ok , I have tried the same with Code::blocks with latest mingw compiler. Is there any way to control the windows allocated memory ?
TuxGeek
A: 

I haven't checked into this with Ming's versions, but we did discover here that meerly including Windows.h adds 19K per object file. We took to manually defining the few things we need from it to save the space.

You might want to play around with removing some of the headers and see what happens to your exe size.

T.E.D.
it does have only windows.h headerfile, very simple application with single window created with CreateWindow and its not about the size of exe , its about the memory that allocates to run the exe.
TuxGeek
+1  A: 

Found one API which can control the application memory set ,

This code can show a better result in Task manager.

SetProcessWorkingSetSize(GetCurrentProcess(), (SIZE_T) -1, (SIZE_T) -1);
TuxGeek