Skip to content

Conversation

@leirocks
Copy link
Contributor

@leirocks leirocks commented Apr 20, 2016

in medium heap blocks, if the object size is bigger than 1 page, it can cause the whole last 1~3 page(s) never been allocated. when such case is hit, decommit those pages to save memory as well as capture corruption. when returning the pages back to page allocator, we should commit those pages again for reuse, in case of OOM here, just decommit all pages in the heap block and let the page allocator to manage the decommitted pages.
in rescan code, asserting that we never scan those unallocatable pages

Fixes #742

@leirocks
Copy link
Contributor Author

@digitalinfinity

@digitalinfinity
Copy link
Contributor

The behavior on free is a little concerning in the case where commit failed. Is it possible to just call PartialDecommit on the decommitted page to update the PageAllocator state and then call release on the entire set of pages? Release doesn't always just decommit, it can also call VirtualFree in some cases, so just decommitting if the commit fails might not be enough.

@dilijev
Copy link
Contributor

dilijev commented May 3, 2016

Is this tied to #742?

@leirocks
Copy link
Contributor Author

leirocks commented May 3, 2016

yes

@leirocks leirocks force-pushed the mediumdecommit branch 2 times, most recently from 655fe7d to 0a9e42f Compare May 5, 2016 23:26
return ((MediumAllocationBlockAttributes::PageCount*AutoSystemInfo::PageSize) % sizeCat) / AutoSystemInfo::PageSize;
}
/* static */
void MediumAllocationBlockAttributes::ProtectUnusablePages(HeapBlock* heapBlock)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure why this is here and not in the HeapBlock- GetUnusablePageCount can be argued as getting an attribute of the block, this is definitely not an attribute. Also, nitpicky but please fix spacing of usage of *- not sure why its the only operator that you use with no spaces

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

leirocks added 4 commits May 11, 2016 09:36
in medium heap blocks, if the object size is bigger than 1 page, it can cause the whole last 1~3 page(s) never been allocated. when such case is hit, decommit those pages to save memory as well as capture corruption. when returning the pages back to page allocator, we should commit those pages again for reuse, in case of OOM here, just decommit all pages in the heap block and let the page allocator to manage the decommitted pages.
in rescan code, asserting that we never scan those unallocatable pages
it's hard to make the partial decommit withou refactoring page allocator, especially in background releasing pages, there will have race issues. changing to protect with NOACCESS for now.
In the future after we implemented the capability of partially commit pages in pageAllocator we can change to use that, because that can save some memories.
@digitalinfinity
Copy link
Contributor

:shipit:

@leirocks
Copy link
Contributor Author

need to merge to master, see #985

@leirocks leirocks closed this May 13, 2016
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.

4 participants