Advertisement
Guest User

Untitled

a guest
Sep 29th, 2010
375
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.90 KB | None | 0 0
  1. DEFAULT_TRIM_THRESHOLD default: 2MB
  2. Also settable using mallopt(M_TRIM_THRESHOLD, x)
  3. The maximum amount of unused top-most memory to keep before
  4. releasing via malloc_trim in free(). Automatic trimming is mainly
  5. useful in long-lived programs using contiguous MORECORE. Because
  6. trimming via sbrk can be slow on some systems, and can sometimes be
  7. wasteful (in cases where programs immediately afterward allocate
  8. more large chunks) the value should be high enough so that your
  9. overall system performance would improve by releasing this much
  10. memory. As a rough guide, you might set to a value close to the
  11. average size of a process (program) running on your system.
  12. Releasing this much memory would allow such a process to run in
  13. memory. Generally, it is worth tuning trim thresholds when a
  14. program undergoes phases where several large chunks are allocated
  15. and released in ways that can reuse each other's storage, perhaps
  16. mixed with phases where there are no such chunks at all. The trim
  17. value must be greater than page size to have any useful effect. To
  18. disable trimming completely, you can set to MAX_SIZE_T. Note that the trick
  19. some people use of mallocing a huge space and then freeing it at
  20. program startup, in an attempt to reserve system memory, doesn't
  21. have the intended effect under automatic trimming, since that memory
  22. will immediately be returned to the system.
  23.  
  24. DEFAULT_MMAP_THRESHOLD default: 256K
  25. Also settable using mallopt(M_MMAP_THRESHOLD, x)
  26. The request size threshold for using MMAP to directly service a
  27. request. Requests of at least this size that cannot be allocated
  28. using already-existing space will be serviced via mmap. (If enough
  29. normal freed space already exists it is used instead.) Using mmap
  30. segregates relatively large chunks of memory so that they can be
  31. individually obtained and released from the host system. A request
  32. serviced through mmap is never reused by any other request (at least
  33. not directly; the system may just so happen to remap successive
  34. requests to the same locations). Segregating space in this way has
  35. the benefits that: Mmapped space can always be individually released
  36. back to the system, which helps keep the system level memory demands
  37. of a long-lived program low. Also, mapped memory doesn't become
  38. `locked' between other chunks, as can happen with normally allocated
  39. chunks, which means that even trimming via malloc_trim would not
  40. release them. However, it has the disadvantage that the space
  41. cannot be reclaimed, consolidated, and then used to service later
  42. requests, as happens with normal chunks. The advantages of mmap
  43. nearly always outweigh disadvantages for "large" chunks, but the
  44. value of "large" may vary across systems. The default is an
  45. empirically derived value that works well in most systems. You can
  46. disable mmap by setting to MAX_SIZE_T.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement