C++ / Win32 and Mem. Usage

Started by
7 comments, last by antareus 19 years, 9 months ago
I just wrote my first semi OOP Win32 Window Wrapper, but I'm a little concerned about it's memory usage. At present it's using an average of 3.84 mb of system memory according to the Task Manager, is this normal or should I consider making a few optimizations to my code? The project I have in mind for the summer could clock up a lot more memory usage as I progress, so I'd prefer not to have a framework thats to memory intensive. Any advice would be greatly appreciated on this! Thanks, Ad!
Advertisement
How much does it use up without use of the wrapper class?

do a sizeof() to find out.
You've lost me! :)

How can I try 'it' without the wrapper, nothing will happen!
How much memory is used when you create a window with an equivalent amount of functionality, without using your wrapper, but instead by just using plain ol' C Win32 programming? My guess is that it'll use just about the same amount anyway. The memory usage is probably coming from Windows, not from your wrapper. Just a guess, though.
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas only, and not for things themselves." - John Locke
If you use Visual Studio, try and turn of debug mode. That probably removes a significant amount of that memory.
--Electron"The truth can be changed simply by the way you accept it.""'General failure trying to read from file' - who is General Failure, and why is he reading my file??"
Oh right, well If i strip out the classes and use C instead, it does around 3mb. I would have thought this is till quite high for whats actually going on?
Check what .lib files you include into your project. visual studio loads a whole bunch by default.
--Electron"The truth can be changed simply by the way you accept it.""'General failure trying to read from file' - who is General Failure, and why is he reading my file??"
Oh yeah and the difference between Debug and Release is around 100kb.
Task manager doesn't show you memory usage, it shows you working set size, which is an approximation of memory usage. Think of it as the number of virtual memory pages that the process 'touched,' as anything can count against it, including (but not limited to) I/O handles, DLLs loaded on the fly by the system, and of course explicit memory allocations. For a newly launched process 3MB is fine, you can get a truer idea of the real memory usage by minimizing and restoring the window.

As for removing libs, don't. The linker in release mode removes unnecessary dependencies.

Also, how much RAM do you have? Windows is more generous with its memory allocations if you have lots of free RAM. After all, there's no use just letting it go to waste. It is hilarious that the "power users," the ones with 1GB of memory, are the ones that are the first to bitch about an app using up 4MB of memory when the app doesn't even have much control over it. See also the ambigious definition of 'bloat.'
--God has paid us the intolerable compliment of loving us, in the deepest, most tragic, most inexorable sense.- C.S. Lewis

This topic is closed to new replies.

Advertisement