The code snippet seems fine and should produce results without any issue. Are you facing OOM with particular type of images with certain file sizes or it is random? Please try to share some images with us with which we can try to replicate the issue in our environment and address it accordingly. Also, please make sure to test with 21.1v of the API before sharing your response.
The usage of this method depends upon the nature of the code routine. The API actually loads resources into memory and keeps them loaded during processing. In a complex code routine, it is necessary to free memory due to which this method was introduced in the API. In your case, as you also mentioned - the API giving OOM exception which indicates that the memory is not being released properly after converting images to PDFs.
You can surely try using this method after saving a Document. In case issue still persists, you can please share sample images in a private message where they will be accessible by only Aspose Staff. We use the files for investigation purposes and erase them from our system once analysis is done.