Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,

when i start my program 1 day later i got out of memory error

how can i fix this?

does any code to clear the memory?

i have an idea which is i start memory clear code every morning,does this possible?

What I have tried:

scaning the code and try to find leak parts
Posted
Updated 10-May-16 22:02pm
Comments
Sergey Alexandrovich Kryukov 11-May-16 2:52am    
The idea is bad. Don't allow any memory leaks at all. Such questions as this one are useless.
Use the leak detection software.
—SA
Richard MacCutchan 11-May-16 3:00am    
No that will not fix it. The problem is that your program is consuming memory but not releasing it. You need to fix the bugs (or the design) in your code.
Patrice T 11-May-16 3:43am    
Your program is guilty consuming all memory.
2 Solutions: don't use it or do corrections.

Avoiding memory leaks is one of the main duties of the software developer. As correctly pointed out by Sergey, your code should correctly handle memory allocation/deallocation.
Hence the right approach here is revising the code in order to make it perform the necessary deallocations.
 
Share this answer
 
v2
Comments
Sergey Alexandrovich Kryukov 11-May-16 4:04am    
You are right, but I voted 4 this time, because the possibilities to track memory leaks are much more advanced with Delphi and Free Pascal; the leaks are found in no time and fixed without any effort. Please see Solution 2.

No Delphi development can be called literate if such tools are not used.

—SA
CPallini 11-May-16 4:21am    
Thank you.
Preventing memory leaks in Delphi is extremely easy, much easier than with most other systems (those without garbage collection, of course). There are products which do all detection for you, without any of your help. It takes just one call to activate them.

I used to use MemChk, it worked flawlessly: MemCheck home page[^].

Presently I use Free Pascal, and highly recommend it, even if you use Delphi; Free Pascal is deeply cross-platform, with very interesting UI abstraction layer, which helps you to develop UI for very many platforms at the same time. It invokes similar memory leak finder automatically, just by checking one of the project options. Most likely, you can fetch its source code and use it for Deplhi as well. It's called Heaptrc. It also works flawlessly. Please see:
heaptrc[^],
leakview[^].

The second link shows advanced usage; in most cases you need nothing of it. Usually, you don't need anything like that.

—SA
 
Share this answer
 
Comments
CPallini 11-May-16 4:20am    
My 5.
Sergey Alexandrovich Kryukov 11-May-16 4:23am    
Thank you, Carlo.
—SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900