summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2009-12-02 13:36:22 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2009-12-02 14:29:23 +0000
commit57473c7f523f476ffa54c34e0c6312ffa66dcc5c (patch)
treed670ad58335b2d7483bb4b12ebb645f74ba4a0cb
parent792fed1e2460f96459141b5a628dd5ab4fbb87db (diff)
intel: Free memory before inserting bo into cache.
This has the unfortunate behaviour of releasing our malloc cache, but the alternative is for X to consume a couple of gigabytes of ram and die during testing. Fortunately the extra mallocs have little impact on performance whereas avoiding swap and death, lots. Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--intel/intel_bufmgr_gem.c13
1 files changed, 10 insertions, 3 deletions
diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c
index ac7297b9..571ab5c8 100644
--- a/intel/intel_bufmgr_gem.c
+++ b/intel/intel_bufmgr_gem.c
@@ -727,9 +727,6 @@ drm_intel_gem_bo_free(drm_intel_bo *bo)
if (bo_gem->gtt_virtual)
munmap(bo_gem->gtt_virtual, bo_gem->bo.size);
- free(bo_gem->reloc_target_bo);
- free(bo_gem->relocs);
-
/* Close this object */
memset(&close, 0, sizeof(close));
close.handle = bo_gem->gem_handle;
@@ -788,6 +785,16 @@ drm_intel_gem_bo_unreference_final(drm_intel_bo *bo, time_t time)
DBG("bo_unreference final: %d (%s)\n",
bo_gem->gem_handle, bo_gem->name);
+ /* release memory associated with this object */
+ if (bo_gem->reloc_target_bo) {
+ free(bo_gem->reloc_target_bo);
+ bo_gem->reloc_target_bo = NULL;
+ }
+ if (bo_gem->relocs) {
+ free(bo_gem->relocs);
+ bo_gem->relocs = NULL;
+ }
+
bucket = drm_intel_gem_bo_bucket_for_size(bufmgr_gem, bo->size);
/* Put the buffer into our internal cache for reuse if we can. */
tiling_mode = I915_TILING_NONE;