System memory 259522560 must be at least 4.718592E8. Please use a larger heap size.

Spark应用启动报错:Error initializing SparkContext. java.lang.IllegalArgumentException: System memory 25952 源码层面分析并解决Spark应用启动报错:Error initializing SparkContext. java.lang.IllegalArgumentException: System memory 259522560 must be at least 471859 阅读详情
AI摘要

本文介绍了解决在Eclipse中开发Spark项目时遇到的内存不足错误的方法。通过调整spark.testing.memory配置,确保分配给JVM的堆内存足够大,从而避免SparkContext初始化失败。

报错内容:

System memory 259522560 must be at least 4.718592E8. Please use a larger heap size.

在Eclipse里开发spark项目,尝试直接在spark里运行程序的时候,遇到下面这个报错:


 

ERROR SparkContext: Error initializing SparkContext.
java.lang.IllegalArgumentException: System memory 468189184 must be at least 4.718592E8. Please use a larger heap size.


 

很明显,这是JVM申请的memory不够导致无法启动SparkContext。但是该怎么设呢?


 

通过查看spark源码,发现源码是这么写的:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
/**
    * Return the total amount of memory shared between execution and storage, in bytes.
    */ 
   private  def getMaxMemory(conf: SparkConf): Long = { 
     val systemMemory = conf.getLong( "spark.testing.memory" , Runtime.getRuntime.maxMemory) 
     val reservedMemory = conf.getLong( "spark.testing.reservedMemory" , 
       if  (conf.contains( "spark.testing" )) 0  else  RESERVED_SYSTEM_MEMORY_BYTES) 
     val minSystemMemory = reservedMemory * 1.5 
     if  (systemMemory < minSystemMemory) { 
       throw  new  IllegalArgumentException(s "System memory $systemMemory must "  + 
         s "be at least $minSystemMemory. Please use a larger heap size." ) 
     } 
     val usableMemory = systemMemory - reservedMemory 
     val memoryFraction = conf.getDouble( "spark.memory.fraction" , 0.75) 
     (usableMemory * memoryFraction).toLong 
   } 

  

所以,这里主要是val systemMemory = conf.getLong("spark.testing.memory", Runtime.getRuntime.maxMemory)。

conf.getLong()的定义和解释是

  1. getLong(key: String, defaultValue: Long): Long  
  2. Get a parameter as a long, falling back to a default if not set  

所以,我们应该在conf里设置一下spark.testing.memory.

通过尝试,发现可以有2个地方可以设置

1. 自己的源代码处,可以在conf之后加上:

    val conf = new SparkConf().setAppName("word count")
    conf.set("spark.testing.memory", "2147480000")//后面的值大于512m即可

2. 可以在Eclipse的Run Configuration处,有一栏是Arguments,下面有VMarguments,在下面添加下面一行(值也是只要大于512m即可)

-Dspark.testing.memory=1073741824

其他的参数,也可以动态地在这里设置,比如-Dspark.master=spark://hostname:7077

再运行就不会报这个错误了。

解决:

Window——Preference——Java——Installed JREs——选中一个Jre 后 
Edit在Default VM arguments 里加入:-Xmx512M

OK!!!

 

标签:  Spark
【大数据】修复 Linux 错误 - 内存不足 内存不足是 Linux 系统常见的问题之一,但是您可以通过检查内存使用情况、查找内存泄漏、优化内存使用和升级硬件来解决该问题。 阅读详情

相关推荐

Spark启动过程中遇到的错误 ./spark-shell –master spark://node001:7077

20/02/20 19:52:17 ERROR spark.SparkContext: Error initializing SparkContext. java.lang.IllegalArgumentException: System memory 259522560 must be at least 471859200. Please increase heap size using the --driver-memory option or spark.driver.memory in Spark configuration.at.org.apache.spark.memory.Uni

ERROR SparkContext: Error initializing SparkContext. ()

在配置yarn的配置文件中设置的内存过小,不能够支持spark程序的运行所以出现了报错。在将spark程序提交到yarn中运行的时出现以下报错。

yujinlong2002的博客 2646

UE4入门实例17(Unreal制作卡通Post Process材质球)

效果展示 #1 创建Post Porcess材质球 #2 编写Shader功能 #3 设置场景区域内风格化渲染 #1 创建Post Porcess材质球 #2 编写Shader功能 创建基础效果 移除现有通道渲染 设置视图渲染范围 #3 设置场景区域内风格化渲染 #4 加群下载Shader源码:284105567 ...

Unity3d 攻城师一枚 1347

ERROR SparkContext: Error initializing SparkContext. java.lang.IllegalArgumentException: System memo

ERROR SparkContext: Error initializing SparkContext. java.lang.IllegalArgumentException: System memory 259522560 must be at least 4.718592E8. Please use a larger heap size. 在Eclipse里开发spark项

xiaoyatouxihuanchen的博客 6017

医疗 java 实战:2.HIS(医院信息系统)对接

HIS(医院信息系统)是医疗机构的核心管理系统,负责患者的挂号、医嘱、收费、病历管理等核心业务。为了与其他系统(如 LIS、PACS、EMR、医保系统)实现数据互通,HIS 需要进行多种方式的对接。:HIS 需要确保与 LIS、PACS、EMR 之间的数据实时同步,避免数据丢失或延迟。:医生在 HIS 开医嘱后,检验信息需要同步到 LIS,LIS 处理检验后返回结果。:HIS 与 LIS、PACS、EMR 交互患者信息、医嘱、检验报告。:HL7 V2.x 消息(ADT、ORM、ORU 等)。

weixin_44743723的博客 3284

VxWorks环境搭建与学习:vxworks6.8和workbench3.2

VxWorks操作系统是美国WindRiver公司于1983年设计开发的一种嵌入式实时操作系统(RTOS),是嵌入式开发环境的关键组成部分。良好的持续能力、高性能的内核以及友好的用户开发环境,在嵌入式实时操作系统领域占据一席之地。它以其良好的可靠性和卓越的实时性被广泛地应用在通信、军事、航空、航天等高精尖技术及实时性要求极高的领域中,如卫星通讯、军事演习、弹道制导、飞机导航等。

qq_41854911的博客 8471

Spark问题:System memory 259522560 must be at least 4.718592E8. Please use a larger heap size.

在本地运行Spark程序时:报出下面的异常: Exception in thread "main" java.lang.IllegalArgumentException:  System memory 259522560 must be at least 4.718592E8. Please use a larger heap size. 这主要是运行内存的问题,所以我们在运行的时候更改JV

一个北漂的程序猿 2259

Matlab实现PSO-TCN-LSTM-Attention粒子群算法优化时间卷积长短期记忆神经网络融合注意力机制多变量时间序列预测的详细项目实例

这些数据包含了随时间变化她动态信息,具有显著她趋势她、周期她和季节她特征。该模型她核心优势在她其能够自适应地学习数据中她多层次时序信息,捕捉时间序列中她长短期依赖关系,从而提高预测她准确她和可靠她。本项目旨在实她一个基她PTO-TCN-LTTM-TFSttfntion她多变量时间序列预测模型,通过粒子群优化算法优化时间卷积长短期记忆神经网络,并融合注意力机制,提高模型她预测精度和稳定她。本项目模型她实她分为多个阶段,首先她数据预处理,接着她PTO优化,然后她TCN和LTTM网络她构建她训练。

优质创作者: 人工智能技术领域 对于有一定基础的 MATLAB和Python带具体需求都可以详谈 MATLAB和Python可以提供代码调试服务加油 谢谢 你的鼓励是我前行的动力 谢谢支持 加油 谢谢 1081

java.lang.IllegalArgumentException: System memory ... must be at least ... Please use a larger heap

java.lang.IllegalArgumentException: System memory 259522560 must be at least 4.718592E8. Please use a larger heap size.解决:设置应用程序的 VM optionsidea的设置路径在:Run -Edit Configurations-Application选择对应的程序,设置VM o

易者悠也 1万+

RAG系统中Reranker模型选型实战

本文详细介绍了RAG系统中Reranker模型选型实战,希望能对学习RAG的同学们有所帮助。 文章目录 1. 前言 2. 思路解析 3. 测评数据集构建 3.1 步骤一 3.2 步骤二 3.3 数据示例 3.4 总结 4. 实战代码 4.1 本地模型 4.2 使用第三方的Reranker模型API

herosunly的博客 17万+

使用Simulink进行四足机器人的非线性动力学建模与仿真

四足机器人的运动包含多个自由度(DOF),包括腿部的摆动和支撑阶段的动力学特性。由于存在接触力、摩擦以及不同地形的影响,四足机器人的动力学行为呈现出高度的非线性特征。因此,构建准确的非线性动力学模型对于研究机器人的运动学和动力学特性至关重要。定义代表机器人状态的变量,如位置、速度、角度和角速度。matlab深色版本通过本指南,我们介绍了如何基于Simulink搭建一个四足机器人的非线性动力学模型,并进行了详细分析。

xiaoheshang_123的博客 311

java.lang.IllegalSystem memory 255459328 must be at least 4.718592E8. Please use a larger heap size.

启动spark提示错误 这是JVM申请的memory不够导致无法启动SparkContext 解决方法: 自己的源代码处,可以在conf之后加上: val conf = new SparkConf().setAppName(“word count”) conf.set(“spark.testing.memory”, “1073741824”)//后面的值大于512m即可 可以在Eclips...

zkhong07的博客 187

【Android逆向工程】第17章:反调试与反 Hook 对抗技术

本文介绍了Android应用常见的反调试技术及其对抗策略。主要内容包括: 反调试技术概述 分类:进程检测(ptrace、TracerPid)、文件检测、行为检测(时间/断点)、内存检测、框架检测 对抗思路:识别检测点→Hook检测函数→修改返回值→隐藏工具特征 ptrace检测实现 原理:利用ptrace系统调用检测调试器附加 实现方式:直接检测、持续线程检测、fork子进程检测 绕过方法:Frida Hook ptrace函数返回0,或使用LD_PRELOAD注入假函数 综合防护 涉及多种检测技术的组合使

w987333120的博客 359

Spark程序运行报错解决(1)

报错内容:System memory 259522560 must be at least 4.718592E8. Please use a larger heap size. 解决:Window——Preference——Java——Installed JREs——选中一个Jre 后 Edit 在Default VM arguments 里加入:-Xmx512M 转...

weixin_30383279的博客 238

【WRF-Chem工具】pyVPRM 计算大气与陆地植被之间的 CO₂ 交换通量

pyVPRM 计算大气与陆地植被之间的 CO₂ 交换通量

WW、forever的博客 210

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

关于ollama报错:“Error: model requires more system memory (7.9 GiB) than is available (1.4 GiB)“

本人在刚好学习了docker的基本使用,又发现ollama这个在本地部署ai的项目正好可以用docker来部署。但我第一次部署本地ai时却收到了这个报错信息,我的电脑内存是32G的,却说我的系统只有1.4G,所以一开始我没有怀疑是内存的问题。在网上找了很多文章都没有提到这个问题的原因是什么,最后问了AI才发现还是内存问题,只不过分配给我的容器的内存真的只有1.4G。

yghr3a的博客 3万+

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

ERROR SparkContext: Error initializing SparkContext.java.lang.IllegalArgumentException: System memor

这是spark2.0之上的版本,也就是sparksql,创建配置的是时候使用SparkSession,。spark2.0之下的可以val conf= new SparkConf() conf.set("spark.testing.memory", "2147480000")//后面的值大于512m即可 报错: 19/10/22 18:02:36 ERROR SparkCont...

weixin_43537911的博客 1932

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

ollama安装遇到问题解决汇总

解决方法:无意间发现系统的防火墙打开了,于是关闭系统的防火墙,问题解决。检查发现进程正常,端口也正常,关掉杀毒软件,最后,

liangyely的博客 3万+

Win安装Spark问题:ERROR SparkContext: Error initializing SparkContext

问题背景: Java版本:1.8.0.291 Spark版本:spark-3.2.0-bin-hadoop3.2 Windows操作系统64位 Spark初次安装 问题描述: 配置完Java环境和Spark路径之后,在cmd中执行Spark-shell时,出现如下错误 Using Spark's default log4j profile: org/apache/spark/log4j-defaults.properties Setting default log level to "WARN".

Circle-C的博客 6336

启动spark-shell出现问题,解决办法

在启动spark-shell出现以下问题: 15/12/30 10:05:29 ERROR SparkContext: Errorinitializing SparkContext. java.lang.IllegalArgumentException: WrongFS:file://219.226.86.159:~/home/iespark/hadoop_program_files/spar

jiaofengaoxue的博客 7833

忽然遇到报错:ERROR spark.SparkContext: Error initializing SparkContext.

java.lang.IllegalArgumentException: System memory 100663296 must be at least 4.718592E8. Please use a larger heap size. 在Eclipse里开发Spark项目,尝试直接在spark里运行程序的时候,遇到下面这个报错: 很明显,这是JVM申请的memory不够

matiji66 2万+

DeepSeek R1 本地部署指南 (5) -Error: model requires more system memory (XX GiB) than is available (XX GiB)

当安装某版本的 deepseek 后执行后:显示 deepseek-r1:671b 版本模型需要更大的物理内存:

Eric Woo 5254

java.lang.IllegalArgumentException: Required executor memory (1024), overhead (384 MB), and PySpark

ERROR spark.SparkContext: Error initializing SparkContext. java.lang.IllegalArgumentException: Required executor memory (1024), overhead (384 MB), and PySpark memory (0 MB) is above the max thre...

Mrerlou的博客 887

Spark :【error】System memory 259522560 must be at least 471859200

https://www.cnblogs.com/drl-blogs/p/11086826.html

Above the cloud 684

llama3.1 本地化部署实践

借助实现模型的本地部署使用,本地使用的操作系统为ubuntu 22.04。

書 6523
上一篇: Caused by: java.lang.ClassNotFoundException: scala.collection.GenTraversableOnce$class
下一篇: class"javax.servlet.ServletRegistration"'s signer information does notmatch signer information of ot
王树民
博客等级 码龄10年 912粉丝 560原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值