Marlon Nardi Posted December 2, 2014 Posted December 2, 2014 Good personal day,for those who like performance with low memory consumption, following a static class that reduces memory consumption in UniGui applications. I'm already using this class on systems that there are many users connected and memory-intensive.to call the class:TGarbageCollector.Execute; unit U_GarbageCollector; interface type TGarbageCollector = class private public class procedure Execute; end; implementation uses Winapi.Windows, Vcl.Forms; { TGarbageCollector } class procedure TGarbageCollector.Execute; var MainHandle : THandle; begin try MainHandle := OpenProcess(PROCESS_ALL_ACCESS, false, GetCurrentProcessID); SetProcessWorkingSetSize(MainHandle, $FFFFFFFF, $FFFFFFFF); CloseHandle(MainHandle); except end; Application.ProcessMessages; end; end. 3 Quote
docjones Posted December 3, 2014 Posted December 3, 2014 I think that it's a bad thing. You're telling to page all your inactive memory to disk. It obeys. The moment you touch any of that memory again, the OS has to page it back into RAM. You're forcing disk I/O that you don't actually know you need. and yes you are releasing memory, but you are forcing disk i/o, if your application is losing memory, that's not the way. 1 Quote
Mohammed Nasman Posted December 4, 2014 Posted December 4, 2014 Hello Marlon, You are not releasing memory, you are forcing your process to move some of it's memory used to the windows swap file, but your process will still allocate the same memory as before. to be sure of that, in task manager, add column "peak working set" next to "memory" column, after executing TGarbageCollector.Execute, the peak memory will remain that same, which is what your process memory, the memory tab only show the current memory using in Ram of your process, but not what your process allocated in memory. docjones, also is right, you are forcing more I/O which will lead to slower performance, but not optimizing the memory. Regards, Mohammed 1 Quote
Administrators Farshad Mohajeri Posted December 4, 2014 Administrators Posted December 4, 2014 When your OS runs out of physical memory it will automatically use virtual memory by writing to swap file. If your app is 32-bit and you hit the upper memory limit your app will crash anyway regardless of physical/virtual memory. Quote
Marlon Nardi Posted December 4, 2014 Author Posted December 4, 2014 Thanks for the personal tips, I analyzed what Mohammed said. Consumes more I / O. Quote
docjones Posted December 4, 2014 Posted December 4, 2014 docjones, also is right, you are forcing more I/O which will lead to slower performance, but not optimizing the memory. Regards, Mohammed Yes, no optimizing memory, only temporally released and writed to disk. regards Quote
Alessandro Posted September 29, 2015 Posted September 29, 2015 Farshad Mohajeri: CPU 2Ghz, RAM 4Gb, Win64bits, virtual Machine in IBM. Quote
picyka Posted September 20, 2019 Posted September 20, 2019 I'm using TMS Aurelius, my server was about to restart IIS every day, I decided to take it, I notice a memory accumulation, but in my tests there is no memory leak, does anyone have any questions to find these problems? Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.