All newly created programs have RefCount == 1, but the fragment program cache
added an additional reference in cache_item, with the result being that none
of the programs were ever freed.
Solve the problem by not creating the additional reference in cache_item.
c->key = _mesa_malloc(sizeof(*key));
memcpy(c->key, key, sizeof(*key));
- _mesa_reference_fragprog(ctx, &c->data, prog);
+ c->data = prog;
if (cache->n_items > cache->size * 1.5) {
if (cache->size < 1000)
create_new_program(ctx, &key, newProg);
+ /* Our ownership of newProg is transferred to the cache */
cache_item(ctx, &ctx->Texture.env_fp_cache, hash, &key, newProg);
}