Mantis Bug Tracker

View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0004773OCaml~DO NOT USE (was: OCaml general)public2009-04-19 16:532015-12-11 19:07
Assigned To 
StatusclosedResolutionno change required 
Platformx86_64OSLinux x86_64OS Version
Product Version3.11.0 
Target VersionFixed in Version 
Summary0004773: Array.make uses twice the required memory
DescriptionCurrently calling 'Array.make (16*1024*1024) 0' uses approximately twice the required memory. This doesn't show up immediately though : on 64bit, resident size climbs to (a bit more than) 128MB while virtual size goes up to (roughly) 230MB.
With linux's overcommit this isn't a problem at first but when compacting, the resident size increases to match the virtual one and I run out of memory.

I tried to pinpoint the problem myself but couldn't manage.

Is it possible to reduce the memory usage ?
Steps To Reproducelet a = Array.make (16*1024*1024) 0 in
let () = Gc.compact () in
read_line ()
TagsNo tags attached.
Attached Files

- Relationships

-  Notes
Camarade_Tux (reporter)
2009-04-19 23:24

I had forgotten about Bigarrays which have let me reduce memory usage (has been divided by three). Now, should int arrays take less memory or should the documentation be extended to warn about memory usage and point to bigarrays ?
doligez (administrator)
2009-05-26 17:30

This is (more or less) done on purpose. Because of the incremental garbage collector, for every 10 bytes that are in use by your data, there are another 8 bytes allocated to hold the dead data that will be reclaimed by the current (or the next) GC cycle. This 80% overhead is the "space_overhead" parameter of the GC. By lowering this parameter, you can reduce memory consumption at the cost of more time spent in the GC. In your case, if you have a few very large arrays with a very long lifetime, you should be able to reduce the space overhead quite a lot without paying too much in terms of run time.

Unfortunately, I don't know of a simple way to do this automatically.

- Issue History
Date Modified Username Field Change
2009-04-19 16:53 Camarade_Tux New Issue
2009-04-19 23:24 Camarade_Tux Note Added: 0004922
2009-04-29 15:59 doligez Status new => acknowledged
2009-05-26 17:30 doligez Note Added: 0004972
2009-05-26 17:31 doligez Status acknowledged => confirmed
2012-07-11 14:54 doligez Status confirmed => resolved
2012-07-11 14:54 doligez Resolution open => no change required
2015-12-11 19:07 xleroy Status resolved => closed
2017-02-23 16:36 doligez Category OCaml general => -OCaml general
2017-03-03 17:55 doligez Category -OCaml general => -(deprecated) general
2017-03-03 18:01 doligez Category -(deprecated) general => ~deprecated (was: OCaml general)
2017-03-06 17:04 doligez Category ~deprecated (was: OCaml general) => ~DO NOT USE (was: OCaml general)

Copyright © 2000 - 2011 MantisBT Group
Powered by Mantis Bugtracker