mempool: rework mempool_cleanup() to only release freed tiles
This substantially reworks mempool_cleanup() so that it releases pools with all freed tiles only, but keeps all pools with still-allocated tiles around. This is more correct, as the previous implementation just released all pools regardless if anything was still used or not. This would make valgrind shut up but would just hide memory leaks altogether. Moreover if called during regular runtime of a program would result in bad memory accesses all over. Hence, let's add a proper implementation and only trim pools we really know are empty. This way we can safely call these functions later, when under memory pressure, at any time.
This commit is contained in:
+1
-1
@@ -25,4 +25,4 @@ static struct mempool pool_name = { \
|
||||
|
||||
__attribute__((weak)) bool mempool_enabled(void);
|
||||
|
||||
void mempool_drop(struct mempool *mp);
|
||||
void mempool_trim(struct mempool *mp);
|
||||
|
||||
Reference in New Issue
Block a user