Enable compiler asset cache for public use, and add changelog entry.

PiperOrigin-RevId: 631352810
Change-Id: If6208327499e3e4bd37cbb2a1b0cdcfb912c1056
This commit is contained in:
Kyle Bayes
2024-05-07 02:49:40 -07:00
committed by Copybara-Service
parent a40de1b230
commit ad0459680d
2 changed files with 34 additions and 22 deletions
+11 -1
View File
@@ -29,6 +29,9 @@
#include "user/user_cache.h"
#include "xml/xml_util.h"
// global cache size in bytes (default 500MB)
static constexpr std::size_t kGlobalCacheSize = 500 * (1 << 20);
// prepend prefix
template <typename T>
@@ -698,5 +701,12 @@ void mj_setCacheSize(mjCache cache, std::size_t size) {
mjCache mj_globalCache() {
return NULL; // currently disabled
// mjCCache is not trivially destructible and so the global cache needs to
// allocated on the heap
if constexpr (kGlobalCacheSize) {
static mjCCache* cache = new(std::nothrow) mjCCache(kGlobalCacheSize);
return (mjCache) cache;
} else {
return NULL;
}
}