Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
memory problems
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Michael Wall <mwall@l...>
Subject: memory problems
hi everyone,

i have an interesting problem i've run into a few times regarding memory
leaks and reference passing.

basically, if i pass a reference to a recursive binding i get a memory
leak when 
i compile with the optimized compiler but if i compile with the bytecode
everything is ok.  eg:

in main:

let maxI = ref 1000 in
let vnew = COMPLEX_HOPFIELD.relax_neat (p, v, h, t, s, n, maxI) in

in relax_neat:

    let rec relax_neat (p, v, h, t, s, n, maxI) = 
      maxI:=!maxI -1;
      let pnew = runge_katta p h t s ({real = 1e-1; imag = 0.0}) n in
      let vnew = p_to_v pnew n in
      let hnew = to_h t vnew s n in
      let eps = COMPLEX_MATH.dis v vnew n in
      if !maxI > 0 && eps > 1.e-15 then (relax_neat (pnew, vnew, hnew,
t, s, n, maxI)) else

i know its the reference be the optimized program ceases to leak when i
remove it.

forgive me if this is a known problem, i am new to caml and this group.

anyones insight into this would be greatly appreciated,


Mike Wall
310-225-2975 ext 156