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

Is there any way to get the size of the cache? #203

Closed
benonymus opened this issue May 12, 2023 · 4 comments
Closed

Is there any way to get the size of the cache? #203

benonymus opened this issue May 12, 2023 · 4 comments

Comments

@benonymus
Copy link

Hey,

We are having a memory leak and I am wondering if what appears to be a memory leak is the cache.
We are using nebulex with shards, partitioned adapter.
Is there a way to get the size of the cache in memory?

Thanks

@cabol
Copy link
Owner

cabol commented May 12, 2023

Hey.

Yes, you can get the cache size by calling the callback c:count_all/2 (e.g.: YourApp.Cache.count_all()). Also, you can configure size/memory limits to the primary/local cache backend for each partition, perhaps if you could share your cache config I could help you out (if you haven't done it already).

Please let me know if that helps, I stay tuned! Thanks!

@benonymus
Copy link
Author

I mean the size as in the size it takes up in memory.
Would writing it to a file with https://hexdocs.pm/nebulex/Nebulex.Cache.html#c:dump/2 give around the same size as the data takes up in memory?

@cabol
Copy link
Owner

cabol commented May 12, 2023

I mean the size as in the size it takes up in memory.

Ok, got it, but yeah, you can only get the number of items in the cache (BTW this is being addressed in the v3).

Would writing it to a file with https://hexdocs.pm/nebulex/Nebulex.Cache.html#c:dump/2 give around the same size as the data takes up in memory?

Yeah, that may give you an idea, but It is not the same, the entries are dumped to the file using Nebulex.Entry.encode/2, which is different how the VM stores them in memory (in the ETS).

@benonymus
Copy link
Author

benonymus commented May 13, 2023

Hey,

Thanks for the info!
I checked the dumped size, I am certain it is not the cache, even with encoding in mind the diff between the memory usage and the size of the cache dump is too much (cache dump was 88kb the memory we are looking for is in the 500 mbs plus).

I am looking forward to v3!

Cheers

This issue was closed.
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