Skip to content

fix memory leak in CCUserDefault (#19853) #19947

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

Merged
merged 1 commit into from
Jul 22, 2019
Merged

Conversation

minggo
Copy link
Contributor

@minggo minggo commented Jul 19, 2019

fastSet makes the Data object managing a new memory area in
[bytes, bytes + size), but it doesn't releasing the old data
it managed. Failure to release the old data causes memory leak.

The default constructed Data manages null memory, so calling
fastSet on it is fine.

Because Data ret = defaultValue; malloc new memory, we might
have better performance without it.

fastSet makes the Data object managing a new memory area in
[bytes, bytes + size), but it doesn't releasing the old data
it managed. Failure to release the old data causes memory leak.

The default constructed Data manages null memory, so calling
fastSet on it is fine.

Because `Data ret = defaultValue;` malloc new memory, we might
have better performance without it.
@minggo minggo added this to the 4.0 milestone Jul 19, 2019
@minggo minggo merged commit b7a6b77 into cocos2d:v4 Jul 22, 2019
@minggo minggo deleted the sync-19853 branch July 22, 2019 02:47
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

Successfully merging this pull request may close these issues.

2 participants