{"record":{"id":"74149c935a798f77","repo":"stanfordnlp/CoreNLP","slug":"cannot-even-create-arrays-of-original-size","errorCode":null,"errorMessage":"CANNOT EVEN CREATE ARRAYS OF ORIGINAL SIZE!!! ","messagePattern":"CANNOT EVEN CREATE ARRAYS OF ORIGINAL SIZE!!! ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"critical","filePath":"src/edu/stanford/nlp/parser/lexparser/ExhaustiveDependencyParser.java","lineNumber":189,"sourceCode":"  public boolean parse(List<? extends HasWord> sentence) {\n    if (op.testOptions.verbose) {\n      Timing.tick(\"Starting dependency parse.\");\n    }\n    this.sentence = sentence;\n    int length = sentence.size();\n    if (length > arraySize) {\n      if (length > op.testOptions.maxLength + 1 || length >= myMaxLength) {\n        throw new OutOfMemoryError(\"Refusal to create such large arrays.\");\n      } else {\n        try {\n          createArrays(length + 1);\n        } catch (OutOfMemoryError e) {\n          myMaxLength = length;\n          if (arraySize > 0) {\n            try {\n              createArrays(arraySize);\n            } catch (OutOfMemoryError e2) {\n              throw new RuntimeException(\"CANNOT EVEN CREATE ARRAYS OF ORIGINAL SIZE!!! \" + arraySize);\n            }\n          }\n          throw e;\n        }\n        arraySize = length + 1;\n        if (op.testOptions.verbose) {\n          log.info(\"Created dparser arrays of size \" + arraySize);\n        }\n      }\n    }\n    if (op.testOptions.verbose) {\n      log.info(\"Initializing...\");\n    }\n\n    // map to words\n    words = new int[length];\n    int numTags = dg.numTagBins();//tagIndex.size();\n    //System.out.println(\"\\nNumTags: \"+numTags);","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/lexparser/ExhaustiveDependencyParser.java#L171-L207","documentation":"After a failed attempt to grow chart arrays for a longer sentence, ExhaustiveDependencyParser.parse tries to recreate arrays at the previous working size (arraySize). If even that allocation fails with OutOfMemoryError, it throws RuntimeException 'CANNOT EVEN CREATE ARRAYS OF ORIGINAL SIZE!!! <arraySize>' — the JVM heap is too exhausted to restore the parser's prior state.","triggerScenarios":"parse() called with a long sentence; growing arrays OOMed; the fallback createArrays(arraySize) also threw OutOfMemoryError — i.e., heap is nearly full at the original chart size.","commonSituations":"Parsing many long sentences in one JVM without releasing memory; -Xmx too small for the grammar/chart; memory leaks from retaining previous parses.","solutions":["Increase JVM heap (-Xmx), e.g. -Xmx4g or more depending on grammar size and maxLength","Reduce testOptions.maxLength to keep chart arrays smaller","Run parsing in a fresh JVM or ensure prior parses/objects are garbage-collectable"],"exampleFix":"// before\njava -Xmx1g ... Parser -maxLength 100 ...\n// after\njava -Xmx8g ... Parser -maxLength 60 ...","handlingStrategy":"try-catch","validationCode":"long maxHeap = Runtime.getRuntime().maxMemory(); if (maxHeap < requiredHeapForGrammar) throw new IllegalStateException(\"Increase -Xmx; heap \" + maxHeap + \" too small for parser chart\");","typeGuard":null,"tryCatchPattern":"try { parser.parse(sentence); } catch (RuntimeException e) { if (e.getMessage().startsWith(\"CANNOT EVEN CREATE ARRAYS\")) { reduceMaxLengthAndRetryOrRestartJvm(); } }","preventionTips":["Size -Xmx generously for the grammar plus O(n^2) charts","Avoid retaining prior parse results; run long batch jobs with periodic JVM restarts","Lower maxLength so array reallocation succeeds even on failure paths"],"tags":["java","parser","memory","out-of-memory","heap"],"backgroundTag":"insufficient-memory","analyzedSha":"1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a","analyzedAt":"2026-09-10T02:24:07.274Z","contentChangedAt":"2026-09-10T02:24:07.274Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}