Making a copy of the dataset in when building the index in the Matlab mex file to fix the issue of Matlab releasing the memory after index was built.