首页 \ 问答 \ 在Eclipse中看堆gcmv使用的堆数量?(Amount used heap looking at gcmv in eclipse?)

在Eclipse中看堆gcmv使用的堆数量?(Amount used heap looking at gcmv in eclipse?)

在Eclipse中使用垃圾收集和内存可视化工具时,我不清楚我的应用程序实际需要多少内存。 看看这张图: gcmv视图

比如0:12它已经获得了超过0.4 GB的数据。 我知道它获得了比实际需要更多的堆(图中的堆大小)。 但我想看到的是它真正使用了多少内存。 另外两张图只是混淆了图片。 我可以在gcmv中这样做吗?


It is not clear to me how much memory my app is actually needs when I use Garbage Collection and Memory Visualizer in Eclipse. Looking at this graph: gcmv view

At say 0:12 it has acquired a bit more than 0,4 GB. I know it acquires more heap (heap size in graph) than actually needs. But what I want to see is how much memory it really uses. The other two graphs just confuses the picture. Can I do that in gcmv?


原文:https://stackoverflow.com/questions/35219963
更新时间:2023-12-14 20:12

最满意答案

虽然我不确定你要用你的函数实现什么,但它不会停止的原因是因为你在无限列表上进行映射并且没有理由停止它。

无限列表源于您对iterate的使用:

lst = (Data.List.iterate id ([1], g_second))

你在那里做的是创建一个无限列表,其中包含无限数量的元组值([1], g_second) 。 这似乎是一个逻辑错误 - 元组列表没有变化; 每个元素都是相同的,无穷大。 要清楚,您正在构建的列表如下所示:

[([1], g_second), ([1], g_second), ([1], g_second), ([1], g_second)...]

g_second是不变的,永远不会有理由进行评估,所以它实际上是被丢弃的。

如果您使用taketakeWhile类的东西,则可以强制该无限列表停止并返回已知数量的元素。 但是,通过在此声明中使用map

map (\x -> (last (fst x))) lst

你所做的就是从元组中提取值1并永远重复它。

由于您丢弃g_second并且从不使用g_first ,因此您的函数等效于以下内容:

rp :: RandomGen g => g -> ([Int], g)
rp g = (repeat 1 , snd (next g))

While I'm not exactly sure what you're trying to achieve with your function, the reason it doesn't stop is because you're mapping over an infinite list and giving it no reason to stop.

The infinite list originates in your use of iterate:

lst = (Data.List.iterate id ([1], g_second))

What you've done there is create an infinite list which contains an infinite number of the tuple value ([1], g_second). That seems like a logic error - that list of tuple has no variation; every element is the same, to infinity. To be clear, this list you are building looks like this:

[([1], g_second), ([1], g_second), ([1], g_second), ([1], g_second)...]

g_second is unchanging and never gets a reason to evaluate, so it is, in essence, discarded.

If you were to use something like take or takeWhile, you could force that infinite list to stop and return a known number of elements. However, by using map in this statement:

map (\x -> (last (fst x))) lst

All you are doing is pulling the value 1 out of the tuple and repeating it forever.

And since you discard g_second and never use g_first, your function is equivalent to the following:

rp :: RandomGen g => g -> ([Int], g)
rp g = (repeat 1 , snd (next g))

相关问答

更多
  • 懒惰评估可以替代宏的某些用途(那些延迟评估来创建控制结构的),但是相反的并不是真的。 您可以使用宏来延迟评估结构的透明度 - 请参阅SRFI 41(Streams)以获得如下示例: http : //download.plt-scheme.org/doc/4.1.5/html/srfi-std/srfi -41 / SRFI-41.html 此外,您还可以编写自己的懒惰IO原语。 然而,在我的经验中,严格语言中的普遍的懒惰代码往往会引入一个开销,相比之下,在运行时的普遍的懒惰代码,旨在从一开始就有效地支持它 ...
  • 主要是因为它可以更有效 - 如果不使用它们,则不需要计算值。 例如,我可以将三个值传递给一个函数,但是根据条件表达式的顺序,实际上只能使用一个子集。 在C语言中,所有三个值都将被计算出来; 但是在Haskell中,只计算必要的值。 它还允许像无限列表一样的酷的东西。 我不能在C语言中有无限列表,但是在Haskell中,这没有问题。 无数列表在数学的某些领域相当频繁地使用,所以有能力操纵它们。 Mostly because it can be more efficient -- values don't ne ...
  • 虽然我不确定你要用你的函数实现什么,但它不会停止的原因是因为你在无限列表上进行映射并且没有理由停止它。 无限列表源于您对iterate的使用: lst = (Data.List.iterate id ([1], g_second)) 你在那里做的是创建一个无限列表,其中包含无限数量的元组值([1], g_second) 。 这似乎是一个逻辑错误 - 元组列表没有变化; 每个元素都是相同的,无穷大。 要清楚,您正在构建的列表如下所示: [([1], g_second), ([1], g_second), ([ ...
  • 也许这些减少可以帮助你: let x `op` y = if x > 2 then 0 else x + y test => foldr op 10 [0..] => 0 `op` foldr op 10 [1..] => 0 + foldr op 10 [1..] => 0 + (1 `op` fold ...
  • 对于大型数据集,懒惰评估不应该更快,它只会推迟评估,直到需要该值为止。 例如,如果你输入你的ghci : fromRange (< 50) (1, 1000000000) 在遍历整个列表之前,您必须等待一段时间,然后将其过滤并打印结果。 另一方面: take 10 $ fromRange (< 50) (1, 1000000000) 将立即完成,因为它不必计算列表的其余部分。 注意:因为它不会找到足够的条目,所以take 100也会挂起。 Lazy evaluation is not supposed ...
  • 我不确定懒惰的评估与代码的性能有多大关系。 我认为主要问题是使用String - 这是一个链表 - 而不是更高性能的字符串类型。 请注意,您的countBetween函数中的此调用: let (topList, bottomList) = splitAt top list 将重新创建与topList相对应的链接链接, topList意味着更多的分配。 可以在此处找到用于比较splitAt与使用take n/drop n的Criterion基准: http : //lpaste.net/174526 。 ...
  • 当x是一个字符对象时,问题就出现了,因为在调用rlasso.formula的环境中没有定义n ,即rlasso.character()或其父项。 这大致是这样发生的: test <- function(x, ...) { UseMethod("test") } test.character <- function(x, pen = list(alpha = n)) { test.formula(x, pen = pen) } test.formula <- function(x, pen = lis ...
  • 这是关键: 可组合性 arr.stream() .filter(Lazy::isGreater) .filter(Lazy::isEven) .map(Lazy::doubleIt) .findFirst(); 这似乎是无害的,但现在这是一个价值: arr.stream() .filter(Lazy::isGreater) 您可以将其交给方法并在其上构建。 什么可以用等效的循环? 您可以在任何地方使用它进行复制粘贴。 它不是一个可组 ...
  • 据我所知,在Matlab中没有更好的方法来实现这一点, 这里也有建议 。 请记住,Matlab不会检测同一术语的多个评估。 如果你做的事情如下: foo = @() 1+1 bar=@()foo()*foo() 它将评估foo两次。 相反,“传统”方式将评估一次: foo=1+1 bar=foo+foo To my knowledge there is no better way to achieve this in Matlab, it's also suggested here. Just keep ...
  • 它太懒了,甚至没有做好工作 - 可能是因为你实际上没有使用操作的结果。 在那里放一个sleep()来确认: > Benchmark.bm do |rep| rep.report('lazy') { num.times do ; arr.lazy.map { |x| sleep(5) }; end } rep.report('notlazy') { 1.times do ; [0,1].map { |x| sleep(5) } ; end } end us ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。