| New Reply |
prevent memory leakage from coding |
Share Thread | Thread Tools |
| Apr5-13, 04:44 AM | #18 |
|
|
prevent memory leakage from coding
I am very grateful!
Many thanks to ScottSalley!!! Your explanation I printed and hung at the computer! |
| Apr21-13, 07:37 PM | #19 |
|
|
What I do to avoid memory leaks is use .NET. It is really pretty difficult to crash a machine using the .NET libraries, and it has very good performance. It is also available for Linux. I did program extensively in C for many years, and my belief is, no matter how "good" you are, how "good" your tools are, and how "good" your design is, if you use C or C++ and program directly in the OS's libraries, you WILL sooner or later get a memory leak, and it may take you a long time to realize it.
Alternatively, you could use Java--or any strongly typed, modern language besides C or C++. |
| Apr22-13, 07:30 AM | #20 |
|
|
Thanks for the advice. But even in Java garbage collector does not solve the problem with memory leaks completely.
|
| Apr22-13, 10:24 AM | #21 |
|
Recognitions:
|
.NET mostly solves the issue of defragging memory when there is is a lot of allocation and freeing of memory, which can create a fragmentation problem even if there are no memory leaks. It does this by occaionally pausing the application and defragging (repacking) memory.
|
| Apr22-13, 12:39 PM | #22 |
|
|
|
| Apr22-13, 03:51 PM | #23 |
|
|
|
| Apr23-13, 05:11 AM | #24 |
|
|
|
| Apr23-13, 06:27 AM | #25 |
|
|
Application layer development with close to the OS programming? Even when I use boost or MPI libs from C++ I don't mess around with sockets, buffers, mallocs and stuff manually, but rely on the robustness of lower layers for those needs. As you rely on the coding done by MS folks when you use .NET, don't you? |
| Apr23-13, 08:34 AM | #26 |
|
|
If you use a language such as Java or C# (or any .NET language) that runs on a framework, it will be less likely to crash, firstly because the languages themselves are strongly typed and take care of allocation and reclaiming automatically with well-tested strategies, and secondly because each process runs in a protected environment such that a poorly-behaved process is not allowed to crash the machine. Also, these languages are just-in-time compiled, which means that once they "warm up" (once most of the code has executed at least once), they are running as native code and run about as fast as C or C++ programs. This is why these languages are so popular and successful, especially for use on web servers. Safety and good behavior sharing a machine. There are times when you need to code down to the metal, and then, and ONLY THEN, would I choose to use C or C++ directly. |
| Apr23-13, 11:19 AM | #27 |
|
|
In fact it's ages ago that I've seen a C/C++/Fortran binary of mine crashing a machine. Sometimes they overheat a node, which is shut down then, but that's a cooling, not a coding issue. On the other hand it seems to magically disappear when it comes to performance issues. For about 20 years yet, I've read about Java either that - its bad performance is simply not existent and my profiling plainly wrong. Period. - Or that the very version will fix exactly that (whatever) issue. |
| New Reply |
| Thread Tools | |
Similar Threads for: prevent memory leakage from coding
|
||||
| Thread | Forum | Replies | ||
| How do memory metals (Shape-memory alloys) work? | Biology, Chemistry & Other Homework | 0 | ||
| What's the difference between short term memory and working memory? | Biology | 2 | ||
| Muscle memory or normal memory? | General Discussion | 1 | ||
| How to let the cold work shape memory alloy to acquire shape memory properties | Materials & Chemical Engineering | 2 | ||
| Verbal memory/semantic memory, also long-term memory | Social Sciences | 0 | ||