Is there a way to computationally prove that a program doesn't contain memory leaks?
And if there's no way to "prove", is there a way to "gain 99% confidence" in the same statement?
Most of static analysis tools check for memory leak bugs.
Related
I have developed a certain tool using OCaml (which was extracted from Coq proofs). I want to do some experiments to empirically observe the memory consumption by this OCaml program.
However, OCaml is a garbage collected language and this makes its behavior of memory consumption somewhat unpredictable and also hard to explain. I would like to somehow tune the garbage collector so that it behaves in a more predictable, preferably eager, fashion.
Is there some way to best tune the Garbage Collector to my needs? For example, is it possible to plugin a different garbage collector into OCaml? Perhaps a more eager one, or something which uses a different mechanism, like reference counting.
One of the solutions I have found so far is to manually trigger the Garbage Collector by using Gc.minor () and Gc.major () from the Gc module. I'd appreciate other suggestions.
I hear a story that:
A man who new a huge memory and set all of them to be zero
and then read them and find there are some are not zero,so it prove that it may be electrical fault?
Does it right?Why?
Your question isn't very clear but it sounds like you are asking if you set all your memory to zero if it's possible to later read back different values due to an electrical fault?
Yes, that's certainly possible. Power spikes can certainly corrupt memory as well as a lot of other things. Some examples here
Is there a way to free up memory used by required gems? My Rails app grows in memory usage and I would like to use gems only when I need them and after that free them up, IF this is possible.
Thanks!
The whole purpose of a memory managed programming language (Ruby) is to avoid developers having to concern themselves with such issues.
If memory does become a sticking point, you'll need to profile the memory by using the following tools
ruby/ruby on rails memory leak detection
Although your control over memory is limited to ensuring memory leaks are avoided and the overall architecture is inline with best practices. An example is ImageMagick takes excessive memory, so rather than having images being converted by all rails mongrels/passengers, restricting the conversion to dedicated ruby services, so as to avoid a large memory footprint.
The Garbage Collector do it this best to you. There are no better solution. Check all part where you can have some memory leak and avoid it. Use less of gems too.
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.
Need a simple code analyzer to see if I am forgetting to free objects and classes, or to see if I am releasing them to many times.
This is built into Delphi's memory manager (FastMM). Set ReportMemoryLeaksOnShutdown true. You can also use the "full debug" version of the memory manager for more detailed checks and information.
The Pascal Analyzer from Peganza does a static analysis of your code.
AQTime from Automated QA is pretty much the defacto standard tool in the Delphi World for profiling for memory leaks (and perf of course)
Another option is a static analysys tool, the only one I know of that supports Delphi is Understand from SciTools it's pretty expensive though.
Simplest tool I've ever used for memory leak checking is MemCheck.
http://v.mahon.free.fr/pro/freeware/memcheck/