VM fix

fix of stackoverflow bug for memory calculation