[haiku-bugs] Re: [Haiku] #12438: Implement brk and sbrk
- From: "korli" <trac@xxxxxxxxxxxx>
- Date: Wed, 20 Jul 2016 06:41:00 -0000
#12438: Implement brk and sbrk
----------------------------+----------------------------
Reporter: simonsouth | Owner: nobody
Type: enhancement | Status: closed
Priority: normal | Milestone: Unscheduled
Component: System/POSIX | Version: R1/Development
Resolution: fixed | Keywords:
Blocked By: | Blocking:
Has a Patch: 0 | Platform: All
----------------------------+----------------------------
Comment (by korli):
Thanks for the review.
Replying to [comment:13 axeld]:
I'm basically okay with the patch, but I have two questions:
1) If only libroot/libgcc will use malloc(), but the app uses sbrk(),
what exactly will happen with your patch? It does look like the two will
interfere now more than before in that use case. Can't we just allocate
the heap as before to avoid this?
libroot/libgcc will use malloc() to init things on library load, but not
after. sbrk() will deliver some memory to hoard and to the app, in this
order, which means interference shouldn't happen (the app can deallocate
up to its allocation with sbrk(), hoard cannot deallocate). Linux does
about the same, doing small allocations first with sbrk(), bigger
allocations though memory areas, which isn't so different on Haiku with
this patch.
I think it's the only usecase we should support, any sane application
should move out of sbrk() anyway.
2) I would actually move the non program base even further down, ie.
like 1.5 GB in order to make more space for the heap (or sbrk). If that
512 MB isn't enough, it will be placed somewhere else, anyway, right? We
could also add some affinity flag, ie. if an area should rather be created
at the start or the end of virtual memory to keep the space for the heap
as large as possible.
Sure I'll check that, though it makes less room for randomizing, this
space will be fragmented anyway.
--
Ticket URL: <
https://dev.haiku-os.org/ticket/12438#comment:14>
Haiku <
https://dev.haiku-os.org>
Haiku - the operating system.
Other related posts: