Merge pull request #1841 from BrzVlad/fix-managed-alloc