MATLAB列的内存配置文件含义 [英] Memory profiling of MATLAB columns meaning

查看:95
本文介绍了MATLAB列的内存配置文件含义的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用MATLAB配置文件通过命令观察内存

I'm using MATLAB profile to observe memory using the command

profile -memory on
profile clear
% my code
profile report

我得到了这张桌子

1-我想问一下 分配的内存,释放的内存,SelfMemory和峰值内存

1- i want to ask about the meaning of Allocated Memory,Freed Memory, SelfMemory, and Peak Memory

2-消极的自我记忆是什么意思?

2- what is the meaning of negative self memory?

推荐答案

快速浏览Google之后,似乎没人知道,除了MathWorks,他们没有告诉. (我开玩笑,但实际上我发现关于该主题的信息很少.)

After a quick google, it would seem that no-one knows, except perhaps MathWorks and they aren't telling. (I jest, but in truth I found very little information on the subject).

但是从逻辑上讲,我将列名称解释如下:

Logically however I would interpret the column names as follows:

已分配的内存=函数及其调用中分配的内存总量.

Allocated memory = the total amount of memory allocated within the function and any it calls.

释放的内存=函数及其调用中释放的内存总量.

Freed memory = the total amount of memory released within the function and any it calls.

峰值内存=函数执行期间任何时候使用的最大内存量.

Peak Memory = the maximum amount of memory in use at any one time during the execution of the function.

Self Memory =该函数使用的内存量,但不包括它调用的任何函数.

Self Memory = the amount of memory used by the function, but not including any functions it calls.

我假设负的"Self Memory"将表示该函数释放的内存大于其分配的内存.这可能是因为它拥有传递给它的一部分数据的所有权,然后将其清除.例如:

I would hypothesize that a negative 'Self Memory' would indicate that the function frees more memory than it allocates. This could be that it has ownership of a piece of data passed to it, which it then clears. E.g.:

function A()
  foo = B();
  clear foo
end

function foo = B()
  foo = rand(10000,10000);
end

在上面的示例中,数据是在对B的调用中创建的,并且由于Matlab采用了惰性复制内存管理,因此在这种情况下,返回值很像按引用传递.因此,B分配内存,而A释放它.

In the example above, the data is created in the call to B and since Matlab employs a lazy copy memory management, this case works pretty much as pass-by-reference for the return value. So, B allocates the memory, and A frees it.

实际上,使用问题中的分析方法运行该代码会产生以下输出,这支持我的假设.

Indeed, running that code with the profiling method in the question produces the following output, which supports my hypothesis.

这篇关于MATLAB列的内存配置文件含义的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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