2016-08-17 6 views
5

के साथ मेमोरी अपवाद से मुझे लिनक्स/रेडहाट पर मेमोरी समस्या का सामना करना पड़ रहा है, और एक ही प्रोग्राम मेरी विंडोज मशीन पर काम करता है।जावा पर लिनक्स-रेडहाट

मेरा लिनक्स मशीन कॉन्फ़िगरेशन 15 जीबी रैम है।

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 totalround = 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, 0, 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()); 
     } 

    } 

} 

मैं के रूप में

java -Xms2048m -Xmx6096m Dwnld 

त्रुटि सैम Eby XMS & के साथ स्मृति में वृद्धि Xmx चला रहा हूँ हो रही है:

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) 
+0

कुछ तुम एक अंत में खंड में अपनी धाराओं बंद हो जाना चाहिए (या संसाधनों के साथ की कोशिश) – Michael

+0

साथ यह उपयोगी हो सकता है - https://plumbr.eu/outofmemoryerror/unable-to-create-new-native -thread – Manish

उत्तर

0

शुरू के साथ करने के लिए मिलता धागा डंप और विश्लेषण करने की कोशिश यह।

  1. /proc/sys/kernel/threads-max फ़ाइल धागे की संख्या के लिए एक प्रणाली चौड़ा सीमा प्रदान करता है:

    वैकल्पिक रूप से कई अन्य तरीके कि समाधान के रूप में कार्य कर सकते हैं कर रहे हैं। जड़ उपयोगकर्ता कि मूल्य बदल सकते हैं अगर वे चाहते हैं:

    $ गूंज 100000>/proc/sys/कर्नेल/धागे-अधिकतम

  2. linux धागे के मामले में सिर्फ एक साझा पता स्थान है और इसलिए साथ प्रक्रियाओं हैं आपको प्रति उपयोगकर्ता प्रक्रियाओं की संख्या जांचनी चाहिए।

  3. थ्रेड पीआईडी ​​सीमा की जांच करें, क्योंकि kernel.pid_max सीमा पैरामीटर के मान के आधार पर अधिकतम पीआईडी ​​सीमा है। अधिकतम स्वीकार्य पीआईडी ​​प्राप्त करने के लिए इस command $ sysctl -a | grep kernel.pid_max का उपयोग करें।
  4. यदि आप ओएस सेटिंग्स को संशोधित करने में सक्षम नहीं हैं तो स्टैक आकार को कम कर रहा है। जैसे JAVA_OPTS="-Xss256k"
संबंधित मुद्दे