void dt_mipmap_cache_cleanup(dt_mipmap_cache_t *cache) { dt_mipmap_cache_serialize(cache); for(int k=0;k<=DT_MIPMAP_F;k++) { dt_cache_cleanup(&cache->mip[k].cache); // now mem is actually freed, not during cache cleanup free(cache->mip[k].buf); } dt_cache_cleanup(&cache->mip[DT_MIPMAP_FULL].cache); // clean up temporary buffers for decompressed images, if any: if(cache->compression_type) { dt_cache_cleanup(&cache->scratchmem.cache); free(cache->scratchmem.buf); } }
int main(int argc, char *arg[]) { dt_cache_t cache; // dt_cache_init(&cache, 110000, 16, 64, 100000); // really hammer it, make quota insanely low: dt_cache_init(&cache, 110000, 16, 64, 100); dt_cache_set_allocate_callback(&cache, alloc_dummy, NULL); #ifdef _OPENMP # pragma omp parallel for default(none) schedule(guided) shared(cache, stderr) num_threads(16) #endif for(int k=0;k<100000;k++) { void *data = (void *)(long int)k; const int size = 0;//dt_cache_size(&cache); const int con1 = dt_cache_contains(&cache, k); const int val1 = (int)(long int)dt_cache_read_get(&cache, k); const int val2 = (int)(long int)dt_cache_read_get(&cache, k); // fprintf(stderr, "\rinserted number %d, size %d, value %d - %d, contains %d - %d", k, size, val1, val2, con1, con2); const int con2 = dt_cache_contains(&cache, k); assert (con1 == 0); assert (con2 == 1); assert (val2 == k); dt_cache_read_release(&cache, k); dt_cache_read_release(&cache, k); } dt_cache_print_locked(&cache); // fprintf(stderr, "\n"); fprintf(stderr, "[passed] inserting 100000 entries concurrently\n"); const int size = dt_cache_size(&cache); const int lru_cnt = lru_check_consistency(&cache); const int lru_cnt_r = lru_check_consistency_reverse(&cache); // fprintf(stderr, "lru list contains %d|%d/%d entries\n", lru_cnt, lru_cnt_r, size); assert(size == lru_cnt); assert(lru_cnt_r == lru_cnt); fprintf(stderr, "[passed] cache lru consistency after removals, have %d entries left.\n", size); dt_cache_cleanup(&cache); exit(0); }
void dt_image_cache_cleanup(dt_image_cache_t *cache) { dt_cache_cleanup(&cache->cache); free(cache->images); }
void dt_image_cache_cleanup(dt_image_cache_t *cache) { dt_cache_cleanup(&cache->cache); }