Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How Do I Clear the Buffer After a Cache Session Is Used to Avoid Memory Usage? #656

Open
huyinmiao opened this issue Jan 15, 2025 · 2 comments
Labels
bug An issue describing a bug in the code

Comments

@huyinmiao
Copy link

huyinmiao commented Jan 15, 2025

Default implementation. Each cache session occupies 512 KB.

Image

Image

@tomaswolf tomaswolf added the bug An issue describing a bug in the code label Jan 15, 2025
@tomaswolf
Copy link
Member

Thanks for reporting this. The intention was that you'd just read from the stream, and it'd reset its buffer itself. The ChannelPipedInputStream does call ByteArrayBuffer.compact() when more than 32kb have been read, or when all available data has been read.

However: when all has been read, then ByteArrayBuffer.compact() does not resize the array but only resets the write and read positions. That's not good.

This will need to be fixed in ChannelPipedInputStream so that the buffer array is cleared on EOF, and is indeed re-set to some small size if all currently available data has been read.

@tomaswolf
Copy link
Member

Also: are you closing the input streams you're reading from when the commands are done? That should also remove the buffers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug An issue describing a bug in the code
Projects
None yet
Development

No branches or pull requests

2 participants