什么能解释FastMM或GetProcessMemoryInfo报告的内存使用差异? [英] What could explain the difference in memory usage reported by FastMM or GetProcessMemoryInfo?

查看:236
本文介绍了什么能解释FastMM或GetProcessMemoryInfo报告的内存使用差异?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Delphi XE应用程序基于单个EXE,使用的是由RemObjects创建的本地服务器DLL,并且对特定操作使用大量内存,直到它生成一个异常(表示没有足够的内存)为止.因此,我试图了解这种情况的发生原因和发生位置,因此在整个代码中放置了多个步骤,以报告内存使用情况.问题是,根据用于获取内存使用情况信息的方法,我得到的信息非常不同:

  1. 如果我使用方法在此处解释,该方法直接向FastMM询问客户端EXE和服务器DLL,则为我得到的:

    • 步骤1:[客户端] = 36664572-[服务器] = 3274976
    • 第2步:[客户端] = 62641230-[服务器] = 44430224
    • 第3步:[客户端] = 66665630-[服务器] = 44430224
  2. 现在,如果我使用使用GetProcessMemoryInfo的方法在此处解释,则会得到更多的内存使用量: /p>

    • 第1步:[过程] = 133722112
    • 第2步:[过程] = 1072115712
    • 第3步:[过程] = 1075818496

基于我的内存问题,似乎第二种方法是正确的,但是FastMM方法怎么会这么低"呢?还有什么可以解释这些差异?

解决方案

GetProcessMemoryInfo还报告了不受FastMM管理的内存,例如由您可能会调用的各种非Delphi dll分配的内存(例如winapi).

FastMM还可以从Windows分配更多的内存,供您的应用程序实际用于内部结构,碎片和池化.

最后,使用GetProcessMemoryInfo测量工作集大小.那就是应用程序内存的当前部分在RAM中,而不是在页面文件中.它不仅包括数据结构,而且绝对不能与应用程序分配的总内存相比. PagefileUsage将更具可比性.工作集的大小几乎永远不会是您想要的.有关更好的说明,请参见此处.

所以它们都给出不同的结果,因为它们都测量不同的东西.

My Delphi XE application is based on a single EXE using a local server DLL created by RemObjects and uses a lot of memory for a specific operation until it generates an exception saying there are not enough memory. So I'm trying to understand why and where this is happening so I placed various steps throughout my code where I report on memory usage. The problem is that I'm getting very different information based on the method used to get memory usage information:

  1. If I use the method explained here which asks FastMM directly for both the Client EXE and Server DLL, here is what I get:

    • STEP 1: [client] = 36664572 - [server] = 3274976
    • STEP 2: [client] = 62641230 - [server] = 44430224
    • STEP 3: [client] = 66665630 - [server] = 44430224
  2. Now if I use the method explained here which uses GetProcessMemoryInfo, I get far more memory usage:

    • STEP 1: [process] = 133722112
    • STEP 2: [process] = 1072115712
    • STEP 3: [process] = 1075818496

It looks like second method is the right based on my memory problems but how could the FastMM method be so "low" ? And what can explain the difference ?

解决方案

GetProcessMemoryInfo also reports memory that is not managed by FastMM, like memory that is allocated by the various non Delphi dlls you might call (like winapi).

Also FastMM can allocate more memory from Windows that your application actually uses for internal structures, fragmentation and pooling.

And as last, with GetProcessMemoryInfo you measuring the Workingset size. That is what part of the application's memory currenctly in RAM instead if in the page file. It includes more than just data structures and is definately not comparable to the total memory the application has allocated. PagefileUsage would be more comparable. Workingset size almost never is what you are looking for. See here for a better explanation.

So they both give different results because they both measure different things.

这篇关于什么能解释FastMM或GetProcessMemoryInfo报告的内存使用差异?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆