[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[MirageOS-devel] Out of memory



I've been trying to track down some occasional out-of-memory errors
with my Mirage/Xen unikernel. My simplified code does this:

let start ... =
    ...
    let rec loop () =
      let open Bigarray in
      let x = Array1.create Char c_layout 1024 in
      (* Gc.minor (); *)
      ignore x;
      loop () in
    loop ()

(note: Cstruct.create uses Array1.create internally)

When run, memory usage (as measured by mini-os's page allocator) rises
from about a third at the start to 100%, and then it dies:

[init]
mm: 2491/7642 (32.6 %)
mm: 2493/7642 (32.6 %)
[...]
mm: 7638/7642 (99.9 %)
mm: 7639/7642 (100.0 %)
mm: 7640/7642 (100.0 %)
mm: 7641/7642 (100.0 %)
mm: 7642/7642 (100.0 %)
Cannot handle page request order 0!
Fatal error: exception Out of memory
Raised at file "src/core/lwt.ml", line 901, characters 22-23
Called from file "lib/main.ml", line 58, characters 10-20
Called from file "main.ml", line 33, characters 6-58
Re-raised at file "main.ml", line 36, characters 10-12
Mirage exiting with status 2
Do_exit called!

If the Gc.minor () line is uncommented then it works.

The C code in caml_ba_alloc does:

    data = malloc(size);
    if (data == NULL && size != 0) caml_raise_out_of_memory();

I guess we should do a GC.full_major here and retry, right? Should
this be changed upstream in OCaml itself?


-- 
Dr Thomas Leonard        http://roscidus.com/blog/
GPG: DA98 25AE CAD0 8975 7CDA  BD8E 0713 3F96 CA74 D8BA

_______________________________________________
MirageOS-devel mailing list
MirageOS-devel@xxxxxxxxxxxxxxxxxxxx
http://lists.xenproject.org/cgi-bin/mailman/listinfo/mirageos-devel


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.