×

Discussion Board

Results 1 to 5 of 5

Threaded View

  1. #1
    Registered User
    Join Date
    May 2013
    Posts
    280

    Uncaught exception java/lang/OutOfMemoryError while adding in vectors

    I am working on s40.I am using following code. This is the parsing code and is running fine till 328 value of vector size but after that it is throwing out of memory error. If it is due to no space left in heap then how should i parse rest of the elements????


    XmlParser parser = null;
    ParseEvent event = null;
    String story_storypath = "";
    Vector v4=new Vector();

    try{
    String url="http://tandonindia.com/story_new_xml?user=1"; //url link (this link contains xml file with each elemnt containing long stories)
    HttpConnection hc = (HttpConnection)Connector.open(url);
    InputStream is = hc.openInputStream();
    Reader reader = new InputStreamReader(is);
    parser = new XmlParser(reader);
    boolean xmlParsingDone = false;
    while (!xmlParsingDone)
    {
    event = parser.read();
    ParseEvent pe;
    switch (event.getType())
    {
    case Xml.START_TAG:
    // Pick up Title for display
    String tagName = event.getName();

    if ("storypath".equals(tagName)) //getting story element from xml file
    {
    pe = parser.read();
    if(pe.getText()!=null)
    {
    story_storypath = pe.getText(); //getting values
    }
    else
    {
    story_storypath="null"; // checking for null values
    }
    System.out.println("TOTAL MEMORY "+Runtime.getRuntime().totalMemory()); //checking total memory
    System.out.println("FREE MEMORY "+Runtime.getRuntime().freeMemory()); //free memory side by side
    v4.addElement(story_storypath);
    System.out.println("sizeeeeeeeeeeeeeeeeeeeeee of storypath--list---------------"+v4.size());
    }
    break;
    case Xml.END_TAG:
    break;
    case Xml.END_DOCUMENT:
    xmlParsingDone = true;
    break;
    case Xml.TEXT:
    break;
    case Xml.WHITESPACE:
    break;
    default:
    }
    }
    System.out.println("sizeeeeeeeeeeeeeeeeeeeeee of storypath--list---------------"+v4.size());
    }
    catch (IOException ioe){

    System.out.println("XML Parsing Error: " + ioe.toString());
    ioe.printStackTrace();
    }finally
    {
    parser = null;
    }
    // TODO Auto-generated method stub
    }
    Last edited by Manpreet_Singh; 2013-06-28 at 06:13.

Similar Threads

  1. Replies: 4
    Last Post: 2012-10-11, 09:57
  2. Error: Uncaught exception java/lang/OutOfMemoryError
    By kumar1234567 in forum Mobile Java Networking & Messaging & Security
    Replies: 5
    Last Post: 2011-07-06, 12:32
  3. Replies: 3
    Last Post: 2011-03-25, 20:22
  4. SUDDENLY ... Uncaught exception java/lang/OutOfMemoryError
    By mbenz1 in forum Mobile Java General
    Replies: 1
    Last Post: 2008-03-15, 23:25
  5. Replies: 2
    Last Post: 2007-09-18, 08:47

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×