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

Yury Molchan edited comment on CXF-9110 at 2/17/25 3:05 PM:
------------------------------------------------------------

Yeah, it will be cleaned by default after 30 minutes. In our real case it is 
not happened due the OutOfMemoryError raised earlier than cleanup happens. 
Because the BufferedOutputStream holds in the memory significant amount of 
bytes, says 20KB, and when the server handles 500 request per second, the 
memory is consumed in 10MB per second, and until the delayed clean up is 
completed, it will consume 18GB memory.

The issue is in that after a response is completed and its OutputStream is 
closed, the stream from the DelayedCleanerImpl.queue is not removed and holds 
till timeout.

If we are configuring to use the minimal time in [2 
seconds|https://github.com/apache/cxf/blob/84a53f9c81fcbb87e0286c9e6df75853c09cd93b/core/src/main/java/org/apache/cxf/io/DelayedCachedOutputStreamCleaner.java#L43],
 it is still raises OutOfMemoryError in our limited memory (512MB), due bigger 
requests till 10MB.

So currently, we have to switch off the cleaner by defining 
{{bus.io.CachedOutputStreamCleaner.Delay=0}}


was (Author: yurkom):
Yeah, it will be cleaned by default after 30 minutes. In our real case it is 
not happened due the OutOfMemoryError raised earlier than cleanup happens. 
Because the BufferedOutputStream holds in the memory significant amount of 
bytes, says 20KB, and when the server handles 500 request per second, the 
memory is consumed in 10MB per second, and until the delayed clean up is 
completed, it will consume 18GB memory.

The issue is in that after a response is completed and its OutputStream is 
closed, the stream from the DelayedCleanerImpl.queue is not removed and holds 
till timeout.

If we are configuring to use the minimal time in 2 seconds, it is still raises 
OutOfMemoryError in our limited memory (512MB), due bigger requests till 10MB.

So currently, we have to switch off the cleaner by defining 
{{bus.io.CachedOutputStreamCleaner.Delay=0}}

> Memory leak in DelayedCleanerImpl.queue when LoggingFeature is enabled
> ----------------------------------------------------------------------
>
>                 Key: CXF-9110
>                 URL: https://issues.apache.org/jira/browse/CXF-9110
>             Project: CXF
>          Issue Type: Bug
>          Components: Core, logging
>    Affects Versions: 4.1.0, 3.6.5, 4.0.6
>            Reporter: Yury Molchan
>            Priority: Major
>         Attachments: image (12).png, image (13).png
>
>
> After migration from 3.6.4 to 3.6.5 (4.1.0) the memory leak appears due the 
> DelayedCachedOutputStreamCleaner does not remove Streams from the 
> DelayedCleanerImpl.queue.
> It happened after CXF-7396 because of the inequality between 
> BufferedOutputStream and LoggingOutputStream instances in [the 
> equals()|https://github.com/apache/cxf/blob/84a53f9c81fcbb87e0286c9e6df75853c09cd93b/core/src/main/java/org/apache/cxf/io/DelayedCachedOutputStreamCleaner.java#L170]
>  method.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to