{"record":{"id":"40b9c68888d292ef","repo":"alibaba/arthas","slug":"object-size-exceeds-size-limit","errorCode":null,"errorMessage":"Object size exceeds size limit: {}","messagePattern":"Object size exceeds size limit: (.+?)","errorType":"exception","errorClass":"ObjectTooLargeException","httpStatus":null,"severity":"warning","filePath":"core/src/main/java/com/taobao/arthas/core/view/ObjectView.java","lineNumber":689,"sourceCode":"     * 是否展开当前深度的节点\n     *\n     * @param deep   当前节点的深度\n     * @param expand 展开极限\n     * @return true:当前节点需要展开 / false:当前节点不需要展开\n     */\n    private static boolean isExpand(int deep, int expand) {\n        return deep < expand;\n    }\n\n    /**\n     * append string to a string builder, with upper limit check\n     * @param buf the StringBuilder buffer\n     * @param data the data to be appended\n     * @throws ObjectTooLargeException if the size has exceeded the upper limit\n     */\n    private void appendStringBuilder(StringBuilder buf, String data) throws ObjectTooLargeException {\n        if (buf.length() + data.length() > maxObjectLength) {\n            throw new ObjectTooLargeException(\"Object size exceeds size limit: \" + maxObjectLength);\n        }\n        buf.append(data);\n    }\n\n    private static class ObjectTooLargeException extends Exception {\n\n        public ObjectTooLargeException(String message) {\n            super(message);\n        }\n    }\n\n    public static int normalizeMaxObjectLength(Integer limit) {\n        if (limit != null && limit > 0) {\n            return limit;\n        }\n        int globalLimit = GlobalOptions.objectSizeLimit;\n        if (globalLimit > 0) {\n            return globalLimit;","sourceCodeStart":671,"sourceCodeEnd":707,"githubUrl":"https://github.com/alibaba/arthas/blob/21cf2e9ba52b305290be7223b980ff504bb9cb5b/core/src/main/java/com/taobao/arthas/core/view/ObjectView.java#L671-L707","documentation":"ObjectView.appendStringBuilder() throws ObjectTooLargeException (a private checked Exception) when the accumulated rendering buffer would exceed maxObjectLength. This is a safety valve to prevent Arthas from rendering and serializing arbitrarily large objects (e.g. deeply nested or huge collections) which could exhaust memory. maxObjectLength defaults to GlobalOptions.objectSizeLimit or ArthasConstants.MAX_HTTP_CONTENT_LENGTH.","triggerScenarios":"Inspecting an object (via ognl/watch/etc.) whose string representation, when rendered with indentation and nesting, pushes the StringBuilder past the configured maxObjectLength threshold.","commonSituations":"Running 'ognl' or 'watch' on a large collection or deeply-nested POJO; the global option objectSizeLimit is set low; inspecting an object that contains a very long string or byte[] rendered as text.","solutions":["Increase the size limit via the global option: options objectSizeLimit <larger-value> (e.g. 10485760 for ~10MB).","Narrow the inspection target — use a more specific OGNL expression to extract only the needed field instead of dumping the whole object.","Reduce the expand depth to avoid rendering deeply nested sub-objects.","If the limit is intentionally low for memory protection, filter or paginate the data at the source before inspection."],"exampleFix":"// before: default limit too small for large object\nognl '@com.example.BigCache@instance' // throws ObjectTooLargeException\n\n// after: raise limit then inspect\noptions objectSizeLimit 10485760\nognl '@com.example.BigCache@instance'\n// or narrow scope:\nognl '@com.example.BigCache@instance.smallField'","handlingStrategy":"validation","validationCode":"// Raise the limit before inspecting large objects (Arthas CLI)\n// options objectSizeLimit 10485760\n// Or programmatically ensure maxObjectLength is sufficient\nint estimated = estimateRenderedSize(target);\nif (estimated > maxObjectLength) {\n    // narrow the inspection target instead of dumping the whole object\n}","typeGuard":null,"tryCatchPattern":"// ObjectTooLargeException is private; callers see a truncated/empty render instead.\n// Prevent by tuning objectSizeLimit or narrowing OGNL expressions.\n// No external try-catch needed — handle by adjusting options.","preventionTips":["Set an appropriate objectSizeLimit for your workload before inspecting large objects.","Use targeted OGNL expressions to inspect specific fields rather than whole objects."],"tags":["arthas","object-view","memory","configuration","size-limit"],"backgroundTag":null,"analyzedSha":"21cf2e9ba52b305290be7223b980ff504bb9cb5b","analyzedAt":"2026-08-14T00:57:07.243Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}