"Igor Mozolevsky" <igor@hybrid-lab.co.uk> writes:For the same reason as it has for the last 20 years or so: memory overcommit, which means that malloc() allocates address space, not memory. Actual memory is allocated on-demand when the address space is used (read from or written to). If there is no RAM left and none can be freed by swapping out, the process gets killed. The process that gets killed is not necessarily the memory hog, it is merely the process that is unlucky enough to touch a new page at the wrong moment, i.e. when all RAM and swap is exhausted *or* everything in RAM is wired down and unswappable. Of course, if you're afraid of memory overcommit and you know in advance how much memory you need, you can simply allocate a sufficient amount of address space at startup and touch it all. This way, you will either be killed right away, or be guaranteed to have sufficient memory for the rest of your (process) lifetime. Alternatively, do what Varnish does: create a large file, mmap it, and allocate everything you need from that area, so you have your own private swap space. Just make sure to actually allocate the disk space you need (by filling the file with zeroes, or at the minimum writing a zero to the file every sb.st_blksize bytes, preferably sequentially to avoid excessive fragmentation) or you may run into the same problem as with malloc() if the disk fills up while your backing file is still sparse. The ability to specify a backing file to use instead of anonymous mappings would be a cool addition to jemalloc. DES -- Dag-Erling Smørgrav - des@des.no _______________________________________________ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
| Jeff Chua | 2.6.27rc1 cannot boot more than 8CPUs |
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Winkler, Tomas | RE: iwlwifi: fix build bug in "iwlwifi: fix LED stall" |
| Evgeniy Polyakov | Re: [BUG] New Kernel Bugs |
git: | |
| David Miller | [GIT]: Networking |
| Gerrit Renker | [PATCH 15/37] dccp: Set per-connection CCIDs via socket options |
| Andrew Dickinson | tx queue hashing hot-spots and poor performance (multiq, ixgbe) |
| David Miller | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
