{"record":{"id":"b5acd06cf7e9c9a3","repo":"stanfordnlp/CoreNLP","slug":"refusal-to-create-such-large-arrays","errorCode":null,"errorMessage":"Refusal to create such large arrays.","messagePattern":"Refusal to create such large arrays\\.","errorType":"exception","errorClass":"OutOfMemoryError","httpStatus":null,"severity":"error","filePath":"src/edu/stanford/nlp/parser/lexparser/ExhaustiveDependencyParser.java","lineNumber":179,"sourceCode":"  public boolean oPossible(Hook hook) {\n    return (hook.isPreHook() ? oPossibleByR[hook.end][hook.head][dg.tagBin(hook.tag)] : oPossibleByL[hook.start][hook.head][dg.tagBin(hook.tag)]);\n  }\n\n  @Override\n  public boolean iPossible(Hook hook) {\n    return (hook.isPreHook() ? iPossibleByR[hook.start][hook.head][dg.tagBin(hook.tag)] : iPossibleByL[hook.end][hook.head][dg.tagBin(hook.tag)]);\n  }\n\n  @Override\n  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        }","sourceCodeStart":161,"sourceCodeEnd":197,"githubUrl":"https://github.com/stanfordnlp/CoreNLP/blob/1b7edd19c4d0d7b1f13a2591425b9b60a0b1af7a/src/edu/stanford/nlp/parser/lexparser/ExhaustiveDependencyParser.java#L161-L197","documentation":"ExhaustiveDependencyParser.parse allocates O(n^2)+ chart arrays; when the sentence is longer than the current arraySize, it refuses to grow arrays beyond the test maxLength (or its own myMaxLength) and throws OutOfMemoryError 'Refusal to create such large arrays.' This is a deliberate guard against absurd memory allocation for over-long sentences.","triggerScenarios":"Calling parse(something) with a sentence whose length exceeds op.testOptions.maxLength + 1 or the parser's myMaxLength, triggering the pre-allocation guard before createArrays is attempted.","commonSituations":"Feeding whole documents/paragraphs as one 'sentence' instead of sentence-splitting first; maxLength option set lower than the actual test data; tokenization producing unexpectedly long inputs.","solutions":["Split input into sentences within maxLength before parsing","Raise op.testOptions.maxLength (and ensure -Xmx heap is large enough for the O(n^2) arrays)","Increase the parser's length limit configuration so the guard permits the sentence length"],"exampleFix":"// before\nparser.parse(longDocumentText); // length > maxLength\n// after\nfor (List<TaggedWord> sent : sentenceSplit(tokenize(longDocumentText))) {\n  if (sent.size() <= op.testOptions.maxLength) parser.parse(sent);\n}","handlingStrategy":"validation","validationCode":"if (sentence.size() > op.testOptions.maxLength) throw new IllegalArgumentException(\"Sentence length \" + sentence.size() + \" exceeds maxLength \" + op.testOptions.maxLength);","typeGuard":"boolean parseable(List<TaggedWord> s, Options op) { return s.size() <= op.testOptions.maxLength; }","tryCatchPattern":"try { parser.parse(sentence); } catch (OutOfMemoryError e) { if (e.getMessage().contains(\"Refusal to create such large arrays\")) { splitAndReparse(sentence); } }","preventionTips":["Sentence-split documents before parsing","Keep testOptions.maxLength in sync with expected data lengths and available heap"],"tags":["java","parser","memory","out-of-memory","length-limit"],"backgroundTag":"file-size-limit-exceeded","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"}