I have a memory problem with the cudd package. I've modified cudd to support custom constant nodes, for example some expression of the form (op x y)
, by adding a new field in the DdNode
's type
union.
I wrote a function that transforms a constant node of type bool to a 0/1-valued BDD node.
the transformation procedure works like Cudd_addApply
with a slight difference: Ite
is used to connect the returned values instead of cuddUniqueInter
, because the return values might have a different index than the original children (sometimes even lower than the current level, causing assertions to fail)
the problem arised when I tried to recollect the intermediate results, this is how I managed the reference counts (NULL checks are removed):
auto n = Cudd_addIthVar(dd, index);
Cudd_Ref(n);
// T, E are transformations of children
res = (T == E) ? T : Cudd_addIte(dd, n, T, E);
Cudd_Ref(res);
Cudd_RecursiveDeref(dd, n); // remove temp results
Cudd_RecursiveDeref(dd, T);
Cudd_RecursiveDeref(dd, E);
cuddCacheInsert1(dd, op, f, res);
Cudd_Deref(res);
return (res);
this approach seems to pass Cudd_DebugCheck
and Cudd_CheckKeys
, but the ref counts of some internal nodes exceed unexpectedly a hundred and the ite operation hangs.