List of usage examples for java.lang OutOfMemoryError getCause
public synchronized Throwable getCause()
From source file:org.ttrssreader.net.JSONConnector.java
/** * parse articles from JSON-reader// ww w . j a va 2 s . c o m * * @param articles container, where parsed articles will be stored * @param reader JSON-reader, containing articles (received from server) * @param skipNames set of names (article properties), which should not be processed (may be {@code null}) * @param filter filter for articles, defining which articles should be omitted while parsing (may be {@code * null}) * @return amount of processed articles */ private int parseArticleArray(final Set<Article> articles, JsonReader reader, Set<Article.ArticleField> skipNames, IArticleOmitter filter) { long time = System.currentTimeMillis(); int count = 0; try { reader.beginArray(); while (reader.hasNext()) { Article article = new Article(); reader.beginObject(); boolean skipObject = parseArticle(article, reader, skipNames, filter); reader.endObject(); if (!skipObject && article.id != -1 && article.title != null) articles.add(article); count++; } reader.endArray(); } catch (OutOfMemoryError e) { Controller.getInstance().lowMemory(true); // Low memory detected } catch (Exception e) { Log.e(TAG, "Input data could not be read: " + e.getMessage() + " (" + e.getCause() + ")", e); } Log.d(TAG, String.format("parseArticleArray: parsing %s articles took %s ms", count, (System.currentTimeMillis() - time))); return count; }