implement some code to cleanup dynamically allocated memory in recursive install function of gpkg