diff --git a/sys/vm/swap_pager.c b/sys/vm/swap_pager.c --- a/sys/vm/swap_pager.c +++ b/sys/vm/swap_pager.c @@ -787,6 +787,20 @@ swp_pager_meta_free_all(object); object->handle = NULL; object->type = OBJT_DEAD; + + /* + * Release the allocation charge. + */ + if (object->cred != NULL) { + swap_release_by_cred(object->charge, object->cred); + object->charge = 0; + crfree(object->cred); + object->cred = NULL; + } + + /* + * Hide the object from swap_pager_swapoff(). + */ vm_object_clear_flag(object, OBJ_SWAP); } diff --git a/sys/vm/vm_object.c b/sys/vm/vm_object.c --- a/sys/vm/vm_object.c +++ b/sys/vm/vm_object.c @@ -702,27 +702,9 @@ } } -/* - * vm_object_destroy removes the object from the global object list - * and frees the space for the object. - */ void vm_object_destroy(vm_object_t object) { - - /* - * Release the allocation charge. - */ - if (object->cred != NULL) { - swap_release_by_cred(object->charge, object->cred); - object->charge = 0; - crfree(object->cred); - object->cred = NULL; - } - - /* - * Free the space for the object. - */ uma_zfree(obj_zone, object); }