Fix memory leak potential of asset api

Fix for #1246