alibaba/arthas · warning · ObjectTooLargeException
Object size exceeds size limit: {}
Error message
Object size exceeds size limit: {} What it means
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.
Source
Thrown at core/src/main/java/com/taobao/arthas/core/view/ObjectView.java:689
* 是否展开当前深度的节点
*
* @param deep 当前节点的深度
* @param expand 展开极限
* @return true:当前节点需要展开 / false:当前节点不需要展开
*/
private static boolean isExpand(int deep, int expand) {
return deep < expand;
}
/**
* append string to a string builder, with upper limit check
* @param buf the StringBuilder buffer
* @param data the data to be appended
* @throws ObjectTooLargeException if the size has exceeded the upper limit
*/
private void appendStringBuilder(StringBuilder buf, String data) throws ObjectTooLargeException {
if (buf.length() + data.length() > maxObjectLength) {
throw new ObjectTooLargeException("Object size exceeds size limit: " + maxObjectLength);
}
buf.append(data);
}
private static class ObjectTooLargeException extends Exception {
public ObjectTooLargeException(String message) {
super(message);
}
}
public static int normalizeMaxObjectLength(Integer limit) {
if (limit != null && limit > 0) {
return limit;
}
int globalLimit = GlobalOptions.objectSizeLimit;
if (globalLimit > 0) {
return globalLimit;View on GitHub (pinned to 21cf2e9ba5)
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.
Example fix
// before: default limit too small for large object ognl '@com.example.BigCache@instance' // throws ObjectTooLargeException // after: raise limit then inspect options objectSizeLimit 10485760 ognl '@com.example.BigCache@instance' // or narrow scope: ognl '@com.example.BigCache@instance.smallField'
Defensive patterns
Strategy: validation
Validate before calling
// Raise the limit before inspecting large objects (Arthas CLI)
// options objectSizeLimit 10485760
// Or programmatically ensure maxObjectLength is sufficient
int estimated = estimateRenderedSize(target);
if (estimated > maxObjectLength) {
// narrow the inspection target instead of dumping the whole object
} Try / catch
// ObjectTooLargeException is private; callers see a truncated/empty render instead. // Prevent by tuning objectSizeLimit or narrowing OGNL expressions. // No external try-catch needed — handle by adjusting options.
Prevention
- Set an appropriate objectSizeLimit for your workload before inspecting large objects.
- Use targeted OGNL expressions to inspect specific fields rather than whole objects.
When it happens
Trigger: Inspecting an object (via ognl/watch/etc.) whose string representation, when rendered with indentation and nesting, pushes the StringBuilder past the configured maxObjectLength threshold.
Common situations: 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.
Related errors
- can not find arthas-core.jar under arthasHome: ${arthasHome}
- File '{}' exists but is a directory
- Arthas server port binding failed! Please check $HOME/logs/a
- can not getResources arthas-bin.zip from classloader: ${clas
- Arthas server port binding failed! Please check $HOME/logs/a
AI-assisted analysis of alibaba/arthas@21cf2e9ba5 (2026-08-14).
Data as JSON: /api/errors/40b9c68888d292ef.
Report an issue: GitHub.