Skip to content
New issue

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

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

Already on GitHub? # to your account

Maybe Memory leak with the latest version #89

Open
cityblack1 opened this issue Sep 25, 2020 · 13 comments
Open

Maybe Memory leak with the latest version #89

cityblack1 opened this issue Sep 25, 2020 · 13 comments

Comments

@cityblack1
Copy link

i find it a little memory leak with the latest version
i try to use tag 1.0.1 then everything is ok

@cityblack1
Copy link
Author

image

@cityblack1
Copy link
Author

expand function cost additional memery than specified init

@coocood
Copy link
Owner

coocood commented Sep 30, 2020

When the values and keys are small, expand could take a portion of the total memory.

@cityblack1
Copy link
Author

When the values and keys are small, expand could take a portion of the total memory.

这个很明显是bug且不符合预期吧。为什么不能逐出一部分空间而是申请新空间呢?

@xunan007
Copy link

xunan007 commented Jan 21, 2021

When the values and keys are small, expand could take a portion of the total memory.

What is the reason for this design?Why not release memory but apply for new memory.

@coocood
Copy link
Owner

coocood commented Jan 21, 2021

Because entry pointers memory is allocated separated, there is no limit for it.

@SupNewBeen
Copy link

Because entry pointers memory is allocated separated, there is no limit for it.

Does that mean Freecache will use more memory than i initialized in NewCache()? Can you provide a more detailed explanation about why expand() uses continuously growing memory instead of clearing unused data? Thanks.

@coocood
Copy link
Owner

coocood commented Sep 13, 2023

Because entry pointers memory is allocated separated, there is no limit for it.

Does that mean Freecache will use more memory than i initialized in NewCache()? Can you provide a more detailed explanation about why expand() uses continuously growing memory instead of clearing unused data? Thanks.

The unused data is cleared, when you repeatedly insert and delete entries, it doesn't grow anymore. but the allocated memory is not shrinked in case more entries need to be added later.

@SupNewBeen
Copy link

Because entry pointers memory is allocated separated, there is no limit for it.

Does that mean Freecache will use more memory than i initialized in NewCache()? Can you provide a more detailed explanation about why expand() uses continuously growing memory instead of clearing unused data? Thanks.

The unused data is cleared, when you repeatedly insert and delete entries, it doesn't grow anymore. but the allocated memory is not shrinked in case more entries need to be added later.

For allocated memory, you mean seg's slosData array? And why allocated memory is not shrinked, doesn't it cause memory usage continually growing and destined to OOM?

@SupNewBeen
Copy link

So the reason why the expand() function occupies excessive memory is that Freecache stores too many entries. To solve this issue, the solution is to reduce the memory size of Freecache and avoid caching such a large number of entries?

@coocood
Copy link
Owner

coocood commented Sep 13, 2023

So the reason why the expand() function occupies excessive memory is that Freecache stores too many entries. To solve this issue, the solution is to reduce the memory size of Freecache and avoid caching such a large number of entries?

yes

@buptSunny
Copy link

So the reason why the expand() function occupies excessive memory is that Freecache stores too many entries. To solve this issue, the solution is to reduce the memory size of Freecache and avoid caching such a large number of entries?

yes

if so, seems like not recommend to use this lib if i have to cache large number of entries??? in live env, memory keeps increasing with this lib

@SupNewBeen
Copy link

So the reason why the expand() function occupies excessive memory is that Freecache stores too many entries. To solve this issue, the solution is to reduce the memory size of Freecache and avoid caching such a large number of entries?

yes

but how many space should i reserve for expand?

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

No branches or pull requests

5 participants