在 Spark 中,当我从一个函数中从 HDFS 读取一个大约 1 GB 的字符串时,我遇到了 java.lang.OutOfMemoryError: Java heap space 错误。我使用的执行程序内存是 6 GB。为了增加用户内存,我什至将 spark.memory.fraction 减少到 0.3,但我仍然遇到同样的错误。似乎降低该值没有效果。我正在使用 Spark 1.6.1 并使用 Spark 1.6 核心库进行编译。我在这里做错了什么吗?
最佳答案
请参阅SparkConf
Spark Executor OOM:如何在 Spark 上设置内存参数 一旦应用程序运行,您将看到的下一个最有可能的错误是 spark 执行程序上的 OOM。 Spark 是一个非常强大的内存计算工具,但它的强大也有一些尖锐的优势。执行程序 OOM 的最常见原因是应用程序试图缓存或加载太多信息到内存中。根据您的用例,有几种解决方案:
增加存储分数变量,spark.storage.memoryFraction。这可以在命令行或 SparkConf 对象中如上设置。这个变量准确地设置了多少 JVM 将专用于 RDD 的缓存和存储。您可以将其设置为 0 到 1 之间的值,描述执行程序 JVM 内存的哪一部分将专用于缓存 RDD。如果您的作业需要很少的随机播放内存,但会使用大量缓存的 RDD,请增加此变量(例如:缓存 RDD,然后对其执行聚合。)
如果所有其他方法都失败了,您可能只需要在每个 worker 上增加 ram。
然后通过在命令行或 SparkConf 对象中设置 spark.executor.memory 变量来增加应用程序请求的 ram 量。
在您的情况下,似乎未应用内存分数设置。正如评论中所建议的那样,您可以打印像这样应用的所有设置以进行交叉检查。
logger.info(sparkContext.getConf.getAll.mkString("\n")
如果不适用,你可以在语法上设置一下,看看效果。
val conf = new SparkConf()
.set("spark.memory.fraction", "1")
.set("spark.testing.memory", maxOnHeapExecutionMemory.toString)
…
如 test 中所述
请通过this nice post更详细地了解
以上帖子的要点是:
You can see 3 main memory regions on the diagram:
1) Reserved Memory : Memory reserved by the system, and its size is hard coded
2) User Memory (in Spark 1.6 “Java Heap” – “Reserved Memory”) * (1.0 – spark.memory.fraction)
This is the memory pool that remains after the allocation of Spark Memory, and it is completely up to you to use it in a way you like.
User Memory and its completely up to you what would be stored in this RAM and how, Spark makes completely no accounting on what you do there and whether you respect this boundary or not. Not respecting this boundary in your code might cause OOM error.3) Spark Memory (“Java Heap” – “Reserved Memory”) * spark.memory.fraction, --> Memory pool managed by Spark. Further divided in to
|--> Storage Memory
|--> Execution Memory
关于java - "spark.memory.fraction"好像没有作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40193649/
我正在尝试测试是否存在表单。我是Rails新手。我的new.html.erb_spec.rb文件的内容是:require'spec_helper'describe"messages/new.html.erb"doit"shouldrendertheform"dorender'/messages/new.html.erb'reponse.shouldhave_form_putting_to(@message)with_submit_buttonendendView本身,new.html.erb,有代码:当我运行rspec时,它失败了:1)messages/new.html.erbshou
我在从html页面生成PDF时遇到问题。我正在使用PDFkit。在安装它的过程中,我注意到我需要wkhtmltopdf。所以我也安装了它。我做了PDFkit的文档所说的一切......现在我在尝试加载PDF时遇到了这个错误。这里是错误:commandfailed:"/usr/local/bin/wkhtmltopdf""--margin-right""0.75in""--page-size""Letter""--margin-top""0.75in""--margin-bottom""0.75in""--encoding""UTF-8""--margin-left""0.75in""-
我好像记得Lua有类似Ruby的method_missing的东西。还是我记错了? 最佳答案 表的metatable的__index和__newindex可以用于与Ruby的method_missing相同的效果。 关于ruby-难道Lua没有和Ruby的method_missing相媲美的东西吗?,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/7732154/
为了将Cucumber用于命令行脚本,我按照提供的说明安装了arubagem。它在我的Gemfile中,我可以验证是否安装了正确的版本并且我已经包含了require'aruba/cucumber'在'features/env.rb'中为了确保它能正常工作,我写了以下场景:@announceScenario:Testingcucumber/arubaGivenablankslateThentheoutputfrom"ls-la"shouldcontain"drw"假设事情应该失败。它确实失败了,但失败的原因是错误的:@announceScenario:Testingcucumber/ar
我有一个奇怪的问题:我在rvm上安装了rubyonrails。一切正常,我可以创建项目。但是在我输入“railsnew”时重新启动后,我有“程序'rails'当前未安装。”。SystemUbuntu12.04ruby-v"1.9.3p194"gemlistactionmailer(3.2.5)actionpack(3.2.5)activemodel(3.2.5)activerecord(3.2.5)activeresource(3.2.5)activesupport(3.2.5)arel(3.0.2)builder(3.0.0)bundler(1.1.4)coffee-rails(
我想在一个没有Sass引擎的类中使用Sass颜色函数。我已经在项目中使用了sassgem,所以我认为搭载会像以下一样简单:classRectangleincludeSass::Script::FunctionsdefcolorSass::Script::Color.new([0x82,0x39,0x06])enddefrender#hamlengineexecutedwithcontextofself#sothatwithintemlateicouldcall#%stop{offset:'0%',stop:{color:lighten(color)}}endend更新:参见上面的#re
如果您尝试在Ruby中的nil对象上调用方法,则会出现NoMethodError异常并显示消息:"undefinedmethod‘...’fornil:NilClass"然而,有一个tryRails中的方法,如果它被发送到一个nil对象,它只返回nil:require'rubygems'require'active_support/all'nil.try(:nonexisting_method)#noNoMethodErrorexceptionanymore那么try如何在内部工作以防止该异常? 最佳答案 像Ruby中的所有其他对象
我真的很习惯使用Ruby编写以下代码:my_hash={}my_hash['test']=1Java中对应的数据结构是什么? 最佳答案 HashMapmap=newHashMap();map.put("test",1);我假设? 关于java-等价于Java中的RubyHash,我们在StackOverflow上找到一个类似的问题: https://stackoverflow.com/questions/22737685/
我遵循MichaelHartl的“RubyonRails教程:学习Web开发”,并创建了检查用户名和电子邮件长度有效性的测试(名称最多50个字符,电子邮件最多255个字符)。test/helpers/application_helper_test.rb的内容是:require'test_helper'classApplicationHelperTest在运行bundleexecraketest时,所有测试都通过了,但我看到以下消息在最后被标记为错误:ERROR["test_full_title_helper",ApplicationHelperTest,1.820016791]test
我正在尝试从Postgresql表(table1)中获取数据,该表由另一个相关表(property)的字段(table2)过滤。在纯SQL中,我会这样编写查询:SELECT*FROMtable1JOINtable2USING(table2_id)WHEREtable2.propertyLIKE'query%'这工作正常:scope:my_scope,->(query){includes(:table2).where("table2.property":query)}但我真正需要的是使用LIKE运算符进行过滤,而不是严格相等。然而,这是行不通的:scope:my_scope,->(que