diff options
author | Søren Sandmann <ssp@redhat.com> | 2010-10-15 10:25:16 -0400 |
---|---|---|
committer | Søren Sandmann <ssp@redhat.com> | 2010-10-15 10:25:16 -0400 |
commit | 47e128ea5791a70e5155fc40be81bddd2b1138d8 (patch) | |
tree | fe1297c68b6f816f18e71ae37a37513a9aee018f | |
parent | ca1952298adf026c1ff18448bafd4570bb880842 (diff) |
Some memory management changes
-rw-r--r-- | src/qxl_driver.c | 10 | ||||
-rw-r--r-- | src/qxl_surface.c | 23 |
2 files changed, 28 insertions, 5 deletions
diff --git a/src/qxl_driver.c b/src/qxl_driver.c index 7300f8e..8b9a86d 100644 --- a/src/qxl_driver.c +++ b/src/qxl_driver.c @@ -132,7 +132,13 @@ qxl_handle_oom (qxl_screen_t *qxl) { outb (qxl->io_base + QXL_IO_NOTIFY_OOM, 0); - // qxl_usleep (10000); +#if 0 + ErrorF ("."); + qxl_usleep (10000); +#endif + + if (!(qxl_garbage_collect (qxl))) + qxl_usleep (10000); return qxl_garbage_collect (qxl); } @@ -145,6 +151,8 @@ qxl_allocnf (qxl_screen_t *qxl, unsigned long size) #if 0 static int nth_oom = 1; #endif + + qxl_garbage_collect (qxl); while (!(result = qxl_alloc (qxl->mem, size))) { diff --git a/src/qxl_surface.c b/src/qxl_surface.c index 432f679..c84fb03 100644 --- a/src/qxl_surface.c +++ b/src/qxl_surface.c @@ -185,6 +185,8 @@ make_surface_cmd (qxl_screen_t *qxl, uint32_t id, qxl_surface_cmd_type type) { struct qxl_surface_cmd *cmd; + qxl_garbage_collect (qxl); + cmd = qxl_allocnf (qxl, sizeof *cmd); cmd->release_info.id = pointer_to_u64 (cmd) | 2; @@ -322,7 +324,7 @@ qxl_surface_create (qxl_screen_t *qxl, static int count; int n_attempts = 0; - if (++count < 200) + if (++count < 10) return NULL; #if 0 @@ -417,25 +419,38 @@ retry: /* the final + stride is to work around a bug where the device apparently * scribbles after the end of the image */ + qxl_garbage_collect (qxl); retry2: surface->address = qxl_alloc (qxl->surf_mem, stride * height + stride); if (!surface->address) { - ErrorF ("- %dth attempt\n", n_attempts); + ErrorF ("- %dth attempt\n", n_attempts++); if (qxl_garbage_collect (qxl)) goto retry2; - if (qxl_handle_oom (qxl) && ++n_attempts < 30000) + ErrorF ("- OOM\n"); + + if (qxl_handle_oom (qxl)) + { + while (qxl_garbage_collect (qxl)) + ; goto retry2; + } - ErrorF ("Out of video memory: Could not allocate %lu bytes\n", stride * height + stride); + ErrorF ("Out of video memory: Could not allocate %lu bytes\n", + stride * height + stride); return NULL; } #if 0 + ErrorF ("Allocated %lu bytes for %p\n", + stride * height + stride, surface->address); +#endif + +#if 0 ErrorF ("Allocated %p\n", surface->address); #endif |