|
-
August 4th, 2004, 04:10 AM
#1
Memory...
Hi all,
I was testing out my application and realised that it uses around 6.0 MB of memory. Is this not a lot???
I could reduce the memory required, but this will only reduce the speed of the app.
e.g. my parser allocates a big chunk of memory, depending on file size, does all the parsing and then deletes the allocated memory.
To improve this, I can allocate memory to parse line by line, deleting each after completion, but this reduces speed!
Its a tough compromise.
What is the recommendation?
Thank you
The most knowledgeable people are those who know that they know nothing.
-
August 4th, 2004, 04:15 AM
#2
Well...I am not sure whether I complety understood...but probablz a memory pool would help....click on the link in my signature to see one example...
-
August 4th, 2004, 05:06 AM
#3
 Originally Posted by Tamerocyte
I was testing out my application and realised that it uses around 6.0 MB of memory. Is this not a lot???
It depends on the type of your application. For a simple text editor, it would be a lot, for a full-blown development environment, it would be rather little memory. For example, when I open TaskManager on my system, I see that MSDEV uses 27.8 MB and Internet explorer 25.7 MB (I wonder how it is possible to write a web browser which needs that much memory...)
 Originally Posted by Tamerocyte
I could reduce the memory required, but this will only reduce the speed of the app.
e.g. my parser allocates a big chunk of memory, depending on file size, does all the parsing and then deletes the allocated memory.
What is the recommendation?
It's a commonplace in CS that you can always trade memory for speed. There can't be a general recommendation - it's up to you to decide whether performance or a low memory footprint are more important for your app. There seems to be a growing tendency, however, for Win32 developers to optimize mostly for speed and ignore memory requirements - after all, virtual memory and the swapfile will fix it (along with a loss of performance, of course )
Just another thing: Have you measured the memory required by your app with a debug build or a release build?
-
August 4th, 2004, 02:03 PM
#4
 Originally Posted by gstercken
I wonder how it is possible to write a web browser which needs that much memory...)
Well...you do not really want to know...
-
August 4th, 2004, 02:37 PM
#5
Unlike gstercken, I think that there is a general recommendation - use as much memory as there is available, unless it hurts some other processes (by causing swap).
My reasoning: I am seating here at the computer with 1GB of RAM, with a peak usage of about 500MB, waiting for some parser to finish its job because you saved those precious 6MB...
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
August 4th, 2004, 02:55 PM
#6
 Originally Posted by VladimirF
Unlike gstercken, I think that there is a general recommendation - use as much memory as there is available, unless it hurts some other processes (by causing swap).
My reasoning: I am seating here at the computer with 1GB of RAM, with a peak usage of about 500MB, waiting for some parser to finish its job because you saved those precious 6MB...
I agree. 6MB is nothing these days.
-
August 4th, 2004, 04:50 PM
#7
 Originally Posted by VladimirF
Unlike gstercken, I think that there is a general recommendation - use as much memory as there is available, unless it hurts some other processes (by causing swap).
My reasoning: I am seating here at the computer with 1GB of RAM, with a peak usage of about 500MB, waiting for some parser to finish its job because you saved those precious 6MB...
Well...I am not sure whether I would consider this as a general recommendation...since I would exactly state the opposite...simply because of havin more or less unlimited resources should not mean that sloppy progamming style is acceptable...and 'wasting' memory jsut because there is enough *is* sloppy programming style in my eyes.
I know many programmers who do not think any longer about the right decision for a datatype, that is, how many bytes are actually needed to hold the data. It does not make sense to use 32 bits if I simply need two...I agree though that using an 'int' is preferrable over a 'short' due to speed optimization. It is of course only a small part and no one gets hurt if it is not being done nowadays, however, I guess it is the problem that I am an old programmer who started on PC's with less resources...
-
August 4th, 2004, 07:02 PM
#8
 Originally Posted by Andreas Masur
...simply because of havin more or less unlimited resources should not mean that sloppy progamming style is acceptable...and 'wasting' memory jsut because there is enough *is* sloppy programming style in my eyes...
I did not advocate using resources simply because they are available. I am saying: if you need them AND they are available - use them. In such case, I would not call that a 'waste'.
Consider this example. You have a 20 - 30 MB dictionary file, and need to repeatedly check incomming words against it. With a maximum word length, say, 32 characters - that is all you need. You would have to read that dictionary every time you get a request, word by word, but you'll use only 32 bytes. I would allocate entire 30 MB, read the whole thing in and be done with that. Would you call that a "waste"? Or would you write your own memory allocation manager? I already have Windows OS for that!
Vlad - MS MVP [2007 - 2012] - www.FeinSoftware.com
Convenience and productivity tools for Microsoft Visual Studio:
FeinWindows - replacement windows manager for Visual Studio, and more...
-
August 5th, 2004, 03:36 AM
#9
 Originally Posted by VladimirF
Consider this example. You have a 20 - 30 MB dictionary file, and need to repeatedly check incomming words against it. With a maximum word length, say, 32 characters - that is all you need. You would have to read that dictionary every time you get a request, word by word, but you'll use only 32 bytes. I would allocate entire 30 MB, read the whole thing in and be done with that. Would you call that a "waste"? Or would you write your own memory allocation manager? I already have Windows OS for that!
Well...no...of course not...I am talking about using memory wisely in regard to the requirements of your application... 
In other words, the mix of wise design and wise resource usage is the key to success in my eyes...in the above case, it would of course makes sense to at least store an index for the dictionary within memory (I would not necessarely hold everything in memory in the first place, however, that would depend on the design of the dictionary etc.)...
-
August 5th, 2004, 04:53 AM
#10
 Originally Posted by gstercken
It depends on the type of your application. For a simple text editor, it would be a lot, for a full-blown development environment, it would be rather little memory. For example, when I open TaskManager on my system, I see that MSDEV uses 27.8 MB and Internet explorer 25.7 MB (I wonder how it is possible to write a web browser which needs that much memory...)
It's a commonplace in CS that you can always trade memory for speed. There can't be a general recommendation - it's up to you to decide whether performance or a low memory footprint are more important for your app. There seems to be a growing tendency, however, for Win32 developers to optimize mostly for speed and ignore memory requirements - after all, virtual memory and the swapfile will fix it (along with a loss of performance, of course  )
Just another thing: Have you measured the memory required by your app with a debug build or a release build?
I measured the memory usage using my debug version, after reading your comments I measured it using the release version:
Debug: 6MB and at peak more
Release: 3MB at peak!!!!
Cool stuff
reg
The most knowledgeable people are those who know that they know nothing.
-
August 5th, 2004, 04:55 AM
#11
 Originally Posted by Tamerocyte
I measured the memory usage using my debug version, after reading your comments I measured it using the release version:
Debug: 6MB and at peak more
Release: 3MB at peak!!!!
Cool stuff
reg
Sorry, after a few more tests I found out it was more like
Debug 6MB
Release 4MB
still cool though!
The most knowledgeable people are those who know that they know nothing.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|