// the mCallback implementation private void onIterate(IntPtr sourceGroup, IntPtr source, uint weight, IntPtr closure) { MamaSource ms = new MamaSource(source); MamaWeightedSource ws = new MamaWeightedSource(ms, weight); mItems.Add(ws); GC.KeepAlive(ms); GC.KeepAlive(ws); }