hadoop - 如何查看hadoop的堆使用情况?

标签 hadoop mapreduce heap-memory

我正在做一项学校作业来分析hadoop中堆的使用。它涉及运行两个版本的 mapreduce 程序来计算论坛评论长度的中位数:第一个是“内存无意识”,reduce 程序在内存中处理每个评论长度的列表;第二个是“内存意识”,reducer 使用一种非常节省内存的数据结构来处理数据。

目的是使用这两个程序来处理不同大小的数据,并观察第一个程序的内存使用情况如何更快地上升(直到最终内存不足)。

我的问题是:如何获取 hadoop 或 reduce 任务的堆使用情况?

我虽然计数器“总提交堆使用量(字节)”会包含此数据,但我发现两个版本的程序返回几乎相同的值。

关于程序的正确性,“无内存”的程序在大量输入时内存不足并失败,而另一个程序没有并且能够完成。

提前致谢

最佳答案

我不知道您使用的是哪种内存意识数据结构(如果您给出哪个可能会有所帮助),但是大多数内存数据结构都利用虚拟内存意味着数据结构大小在一定程度上基于策略额外数据而增加element/s 将被转储到虚拟内存中。因此,我们不会导致内存不足错误。但万一内存无意识不这样做。在这两种情况下,数据结构大小都将保持不变,这就是您获得相同大小的原因。要获得 Reducer 的实际内存使用情况,您可以通过以下方式获得它:

Java 1.5 添加的新功能是 Instrumentation您可以通过该接口(interface)获取对象的内存使用情况(getObjectSize)。关于它的好文章:LINK

/* Returns the amount of free memory in the Java Virtual Machine. Calling the gc method may result in increasing the value returned by freeMemory.*/
long freeMemory = Runtime.getRuntime().freeMemory()


/* Returns the maximum amount of memory that the Java virtual machine will attempt to use. If there is no inherent limit then the value Long.MAX_VALUE will be returned. */
long maximumMemory = Runtime.getRuntime().maxMemory();


/* Returns the total amount of memory in the Java virtual machine. The value returned by this method may vary over time, depending on the host environment.
Note that the amount of memory required to hold an object of any given type may be implementation-dependent. */
long totalMemory = Runtime.getRuntime().totalMemory()

关于hadoop - 如何查看hadoop的堆使用情况?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17251640/

相关文章:

java - Hadoop MapReduce中的Dijkstra-选择无限距离

hadoop - hadoop-streaming:将输出写入不同的文件

c - 为什么 strsep() 不适用于指向堆栈的指针?

来自 Wuala 的 java 堆空间错误

hadoop - 从多个链接访问 hadoop 节点 web UI

java - HBase PerformanceEvaluation,如何分配columnFamily和列名?

java - 在第二次MR期间未创建文件

hadoop - hadoop mapreduce分区程序未调用

macos - OSX 上的 IntelliJ Idea 2016 内存问题

hadoop - 如何设置hdfs中文件的行组大小?