Any decent library (of any sort) should already be providing hooks for its memory allocation. This isn&#x27;t necessarily provided as a security feature, and it&#x27;s common for your callbacks not to get much in the way of information about what&#x27;s going on, but it will allow you to at least crudely put a cap on the library&#x27;s memory usage.