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

[Core] Fix COW allocates too much memory #91286

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions core/templates/cowdata.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,10 @@ class CowData {
}

_FORCE_INLINE_ USize _get_alloc_size(USize p_elements) const {
return next_po2(p_elements * sizeof(T));
return next_po2(p_elements) * sizeof(T);
}

_FORCE_INLINE_ bool _get_alloc_size_checked(USize p_elements, USize *out) const {
if (unlikely(p_elements == 0)) {
*out = 0;
return true;
}
Nazarwadim marked this conversation as resolved.
Show resolved Hide resolved
AThousandShips marked this conversation as resolved.
Show resolved Hide resolved
#if defined(__GNUC__) && defined(IS_32_BIT)
USize o;
USize p;
Expand All @@ -157,7 +153,7 @@ class CowData {
// and hope for the best.
*out = _get_alloc_size(p_elements);
#endif
return *out;
return true;
}

void _unref(void *p_data);
Expand Down
Loading