[ 
https://issues.apache.org/jira/browse/SLING-7969?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16749940#comment-16749940
 ] 

Timothee Maret commented on SLING-7969:
---------------------------------------

Looking at the Johnzon code base, it seems that the support for auto adjusting 
buffer has been added and enabled by default as part of 
[JOHNZON-125|https://jira.corp.adobe.com/browse/JOHNZON-125] in the commit 
[d5ba838e|https://github.com/apache/johnzon/commit/d5ba838e476ae59aae883f9f582dad2e70d6a346#diff-72ad12815bbfcf2af29bf57c8e965ae2R67]
 and the default buffer has been adjusted to 256KB (from 10MB) as part of in 
JOHNZON-134 in the commit 
[d7a4a2f9|https://github.com/apache/johnzon/commit/d7a4a2f9de8c39b84fbb8b73b13c6f7f6514a9cf#diff-72ad12815bbfcf2af29bf57c8e965ae2R67].

Both fixes should be contained in 
[johnzon-core/1.1.4|https://search.maven.org/artifact/org.apache.johnzon/johnzon-core/1.1.4/bundle]
 onward.

> Memory leak in DiscoveryLiteDescriptor
> --------------------------------------
>
>                 Key: SLING-7969
>                 URL: https://issues.apache.org/jira/browse/SLING-7969
>             Project: Sling
>          Issue Type: Bug
>          Components: Discovery
>    Affects Versions: Discovery Commons 1.0.20
>            Reporter: Timothee Maret
>            Assignee: Timothee Maret
>            Priority: Major
>              Labels: discovery
>
> As identified in [~volteanu]'s adaptTo 
> [presentation|https://adapt.to/2018/en/schedule/sling-memory-deep-dive.html], 
> it seems that Sling Discovery on Oak is consuming 42MB of RAM on a standard 
> instance.
> Sling discovery deals with transient states (the views, leases, etc.) and is 
> not caching significant amount of data. The 42MB figure for the discovery 
> feature seems like a symptom of a memory leak.
> [~volteanu] shared in his presentation that the 42MB worth of RAM was mainly 
> consumed by a Json Factory reference. There is one static JsonReaderFactory 
> in the discovery commons module, in the 
> [DiscoveryLiteDescriptor|https://github.com/apache/sling-org-apache-sling-discovery-commons/blob/master/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/DiscoveryLiteDescriptor.java].
> Looking at the code, it seems that each invocation of the 
> [getDescriptorFrom|https://github.com/apache/sling-org-apache-sling-discovery-commons/blob/master/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/DiscoveryLiteDescriptor.java#L51]
>  method creates a JSON reader but never close it. This may may leave 
> resources behind as hinted by the description of the 
> [close|https://docs.oracle.com/javaee/7/api/javax/json/JsonReader.html#close--]
>  method in the API. AFAIK, the 
> [getDescriptorFrom|https://github.com/apache/sling-org-apache-sling-discovery-commons/blob/master/src/main/java/org/apache/sling/discovery/commons/providers/spi/base/DiscoveryLiteDescriptor.java#L51]
>  is invoked periodically on a relatively high frequency (< seconds) which may 
> be the trigger for the leak on all instances.
> This is only a supposition for now, it should be investigated further, simply 
> by running a patched version of \{{org.apache.sling.discovery.commons}} that 
> make sure each JSON reader is properly closed.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to