大佬教程收集整理的这篇文章主要介绍了使用linux-redhat的java上的内存不足,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
我的linux机器配置是15Gb RAm.
import java.awt.image.bufferedImage; import java.io.File; import java.io.FiLeoutputStream; import java.io.InputStream; import java.io.outputStream; import java.net.URL; import java.sql.ResultSet; import javax.imageio.ImageIO; import javax.swing.ImageIcon; /** * * @author ndoshi */ public class Dwnld { BufferedImage bi8 = null,bi16 = null; ImageIcon ii = null; ResultSet rs,rsDwnld; String OG = "ogImage\\"; String CROP8 = "Crop8\\"; String CROP16 = "Crop16\\"; String TIME = "",ErrorLog = "",ErrorLogPro = ""; int hashInc8 = 0; int hashInc16 = 0; int @R_124_10586@lround = 0; int countProcess = 0; Boolean download_new = false; privatE int row = 0; int Dwnld = 0,NotDwnld = 0; final String OP_Log = "Log",OP_Error = "ErrorLog",OP_ErrorPro = "ErrorLogProcess"; int r,g,b,k,ih,j; int sr = 0,sg = 0,sb = 0,sk = 0; int rg,gg,bg,kg; String s = "",s1 = "",hash16,hash8; /** * @param args the command line arguments */ public static void main(String[] args) { new Dwnld(); } public Dwnld(){ try { BufferedImage image = null; InputStream is = null; OutputStream os = null; URL url = new URL("https://rukminim1.flixcart.com/image/312/312/t-shirt/u/g/k/33solidblackmelangeblack-sayitloud-m-original-imaehfytzzzazfyf.jpeg?q=70"); is = url.openStream(); os = new FiLeoutputStream(OG + "1.jpg"); byte[] b = new byte[2048]; int length; while ((length = is.read(b)) != -1) { os.write(b,length); } image = ImageIO.read(new File(OG + "1.jpg")); is.close(); os.close(); System.out.println("Hash 16 = "+hash16); System.out.println("Hash 8 = "+hash8); } catch (Exception eX) { System.out.println(ex.getmessage()); } } }
我正在运行sam eby通过XMS和&增加内存. XMX为
java -Xms2048m -Xmx6096m Dwnld
得到错误:
Exception in thread "main" java.lang.outOfMemoryError: unable to create new native thread at java.lang.Thread.start0(Native Method) at java.lang.Thread.start(Thread.java:714) at sun.security.ssl.SSLSocketImpl.readRecord(SSLSocketImpl.java:1056) at sun.security.ssl.SSLSocketImpl.performInitialHandshake(SSLSocketImpl.java:1332) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1359) at sun.security.ssl.SSLSocketImpl.startHandshake(SSLSocketImpl.java:1343) at sun.net.www.protocol.https.httpsClient.afterConnect(httpsClient.java:563) at sun.net.www.protocol.https.AbstractDelegatehttpsURLConnection.connect(AbstractDelegatehttpsURLConnection.java:185) at sun.net.www.protocol.http.httpURLConnection.geTinputStream(httpURLConnection.java:1301) at sun.net.www.protocol.https.httpsURLConnectionImpl.geTinputStream(httpsURLConnectionImpl.java:254) at java.net.URL.openStream(URl.java:1037) at Dwnld.<init>(Dwnld.java:53) at Dwnld.main(Dwnld.java:43)
> / proc / sys / kernel / threads-max文件提供了线程数的系统范围限制. root用户可以更改该值,如果他们希望:
$echo 100000>的/ proc / SYS /内核/线程-MAX>在Linux的情况下,线程只是具有共享地址空间的进程,因此您应该检查每个用户的进程数.>检查线程PID限制,因为根据kernel.pid_max limit参数的值有最大PID限制.使用此命令$sysctl -a | grep kernel.pid_max获取最大允许PID.>如果您无法修改操作系统设置,则会减小堆栈大小.像JAVA_OPTS =“ – Xss256k”
以上是大佬教程为你收集整理的使用linux-redhat的java上的内存不足全部内容,希望文章能够帮你解决使用linux-redhat的java上的内存不足所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。