Reduce the amount of memory used by Delphi programs

Source: Internet
Author: User

Recently in writing a backdoor program, inadvertently see such a piece of code, tried, and sure enough effective. The original program consumes more than 5M of memory, and sure enough to 600K, but expect the code execution efficiency may be reduced, because the original pre-allocated memory space may become dynamic, but for my program speed is not a problem.

From http://www.cn-doc.com/_soft_delphi_tech_doc/2005_08_18_01/20050818012858312.htm

  have not written blog for many days, recently solved a problem-reduce memory consumption. However, this method can only be applied in winxp,win2k and does not show the best program that the main form has been running. The previous program consumes 11m of memory, I can only reduce the method of dynamically creating Windows to 100k, after applying this method memory occupies only 496k. Put the following procedure in a timer, once every time, such as 5 seconds.
{
************************************
* Clear Memory
* from muse2008
****************************
}
procedure clearmemory;
Begin
        If win32platform = Ver_platform_win32_nt then
         begin
                 setprocessworkingsetsize (getcurrentprocess, $FFFFFFFF, $FFFFFFFF);
                Application.processmessages;
        end;
End;  

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.