Skip to content

Instantly share code, notes, and snippets.

View nullsub's full-sized avatar
✈️

Christian Deussen nullsub

✈️
View GitHub Profile
@karthick18
karthick18 / brk_cow.c
Created June 17, 2011 23:08
Just an example to remind that its futile to free memory in the child to avoid taking a break COW perf. hit. Check the header comments for more details.
/*
* Just an example to remind that its futile to free memory in the child
* allocated by the parent to avoid taking a break COW perf. hit.
* Makes sense only to free large chunk sizes in the child. Smaller chunk sizes
* aren't really trimmed by malloc and only end up causing perf hits with
* break COW pages (copy on write) when freeing in the child.
* A break COW is when free results in malloc lib. touching the freed chunk
* of memory resulting in a write protection page fault for the child that ends up
* unmapping the shared page table entry and then maps a writable page copy to the child.
* The net effect for RSS(resident set size) is the same as in the parent but