Measure How much memory a program will need - memory

Is it possible to know how much memory a program will need?

The usual method is to use some form of profiler. Many IDEs include their own, Netbeans for example has a particularly good profiler (in my opinion) for Java applications. This will show the memory consumption of your program as its running, and is good for testing for things such as memory leaks as well as overall consumption.
If you've only got the binary, then you'll just have to use a basic tool such as task manager or pmap. This won't give you nearly as much detail though.

if you're using an IDE then it will probably have some in-built feature by which you can see the same...
In case you are executing directly, I guess probably the Task Manager is the best way.

Related

Memory Profiling Existing Process in VS2012

I am not able to profile memory allocation using the VS 2012 built-in profiler when connecting to an existing web application process.
When I Start profiling and let it launch the process it works fine, but if I try and attach to an existing process it reverts to CPU sampling instead of memory allocation. There is no warning that this is going to happen.
Does anyone know of a reason why this would be the case?
Update
I'm willing to accept that this is a limitation of the profiler (although letting me know that it is falling back this to this functionality would be nice). There are ways around it.
Use a different profiler. I used this one and can recommend it.
Profile from the start and filter results.
I've certainly moved on.
This is almost certainly a limitation of the profiler. I'm sure other profilers can do this if you really need it.
The built in VS 2012 profilers are great for basic needs but for anything advanced I would go for something else.
Many of the more advanced profilers are not free, but often have a trial period. This is a good one in my opinion.
.Net Memory Profiler but SciTech Software

Is 15 MB RAM acceptable?

I am writing an application in Python that functions as a daemon, and performs a relatively trivial task in the background. By trivial I mean it waits for keystrokes and plays certain sounds when detected.
I am getting around 15 MB of RAM usage for the python process. Would you consider this acceptable for a small application? It has very low CPU usage.
Thanks in advance.
15Mb for such a small app is too much. If you can bring it down by changing the source code, you should.
However, it's possible that Python by itself has some fixed overhead. Whether you are OK with paying that cost just to get the Python language for something so simple, is up to you. But in my opinion it might not be worth it and I'd consider different platform for this scenario.
Note that this is not to say that there's anything inherently wrong with Python; there are scenarios where such an overhead might be acceptable cost compared to the benefits and simplicity of language and the ease of implementing complex scenarios with it.
All I am saying is - use the right tool for the task; Python might not be the right one for this task.

How to find "fat" procedure memory usage?

While working on my code lately, I've noticed that some of the memory usage is going up significantly, and I can't see many reasons for it in my code. So I'm wondering if there are any programs, techniques, or other types of tools that can scan my code (Delphi) and estimate for me what procedures, functions, and functions will be the heaviest memory users. Ideally, I' think I'd be looking at the code as it is run in debug mode, but if something can scan the source files and tell me, that would be even better. Thanks.
The type of tool you are looking for is a Profiler. There are lots of good profilers out there for most languages. I'm less familiar with Delphi though so I used google and it turned the following options
http://www.prodelphi.de/
http://delphitools.info/
But the best information seems to be on this question from StackOverflow
Delphi Profiling tools
See my answer to a similar question:
Memory profiling tool for Delphi?
Without knowing how you are currently measuring "memory use" it's difficult to say what might be the best tools to use.
We have used AQTime in the past it found a load of memory leaks.
http://www.automatedqa.com/products/aqtime/
another good Delphi tool is Eurekalog

How to profile?

I've developed a little screenshot application but I've heard that I should profile my code to see where it's using a lot of resources and stuff.
What is a profiler? what does it do? Where can i get it for free? and How do I use it?
A profiler is a software tool which intercepts and measures every executed code path in a certain run of an application. They store this information and later report graphically (or tabularly) where does your code spend most of the running time so you can optimize where it really matters.
About where to get one, it depends on your platform/language combination.
What language are you developing in? For C#, check this question.
Any decent C# profilers out there?
Here's one for C++
Decent profiler for Windows?
In fact, check the profiler tag to see all the questions tagged in connection with profilers.
https://stackoverflow.com/questions/tagged/profiler
See:
what-techniques-can-you-use-to-profile-your-code
You didn't say what language you use. For C/C++ (and probably others) a free ones are:
gcov
gprof

How does the memory footprint of some common web framework(s) compare?

Hypothetically, if I were to build the same app using a few popular/similar frameworks, say PHP(cakePHP|Zend), Django, and Rails, should the memory consumption of each be roughly the same?
Also, I'm sure many have evaluated or used each and would be interested in which you settled on and why?
Code with whatever framework you like best. Then pray your app is popular enough to cause memory problems. We should all be so lucky.
No, it will absolutely vary wildly from one framework to another.
That said, in most cases the memory footprint of the framework is not the determining factor in site performance nor in selection of a framework. It's usually more a matter of using the right tool for the job, since each framework has its own strengths and weaknesses.
It is hard to efficiently say, I would say that PHP frameworks will have mostly a similar footprint, which is typically less than other frameworks such as Rails and Django. But it depends what you include as rails, such as mongrel (rails server proxy). Overall it depends on your code as well however PHP will most of the time give an easier time on the server. (Without any language Bias, I use both PHP and Rails)
Just for getting some perspective let me report a real case memory consumption using a Smalltalk web framework AIDA/Web.
For running 40+ websites on a single Smalltalk image on a single server it currently consumes 330MB of memory.
The only one of those frameworks I have used is CakePHP. I found that it's not to bad footprint wise however it is a lot more heavy that normal PHP without using a framework obviously but can be a good trade off.
A good comparison of some of the most popular PHP frameworks can be found at http://www.avnetlabs.com/php/php-framework-comparison-benchmarks.
Memory is cheap these days. Go with what will make your development easiest (which is usually what your team knows best).
But... In my experience, Django isn't terribly memory hungry. I've run it on my shared host with less than 100 MB of RAM. But my experience is sheerly anecdotal. YMMV. If you go with Django, here are some tips to keep memory usage down.
EDIT: And don't go with zope if memory footprint is important to you.

Resources