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

Allow for setting an upper limit on memory usage #34

Open
gurre opened this issue Jul 9, 2019 · 2 comments
Open

Allow for setting an upper limit on memory usage #34

gurre opened this issue Jul 9, 2019 · 2 comments

Comments

@gurre
Copy link

gurre commented Jul 9, 2019

When a system is under high load the cache might grow to the point when it's consuming all available memory on the system it's running.

Consider adding some kind of upper limit to how much resources are occupied e.g. max items or max memory used. Memory usage could be calculated for structs using unsafe.Sizeof if the security requirements are accepting.

@muesli
Copy link
Owner

muesli commented Jul 9, 2019

I've looked into that before, but sadly there's no way to measure how much memory the stored data interface{} occupies:

For instance, if x is a slice, Sizeof returns the size of the slice descriptor, not the size of the memory referenced by the slice

@gurre
Copy link
Author

gurre commented Jul 9, 2019

The most sensible solution would be to serialize everything to []byte using encoding/gob.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants