- 20150113.21:13:21 wim | hi guys, after using tmux for a while it seems like it's using quite some memory (using 1.9a).
- 20150113.21:13:44 wim | 128Mb at the moment for 8 windows
- 20150113.21:14:31 wim | memory leak?
- 20150114.00:47:03 nicm | tmux returns memory to libc and is reliant on it to return it to the kernel
- 20150114.00:47:14 nicm | glibc does not do so very aggressively
- 20150114.00:47:19 nicm | this is a common issue on linux
- 20150114.00:47:48 nicm | there is a library call you can put into tmux if you want it to be returned more quickly
- 20150114.00:48:32 nicm | malloc_trim(3)
- 20150114.00:50:08 nicm | add malloc_trim(0) somewhere, server_second_callback in server.c would be a good place, or grid_destroy in grid.c
- 20150114.00:50:24 nicm | or just live with it and assume glibc knows best
- 20150114.00:51:23 nicm | i believe OS X is similar, if not worse, although it has different ways to reclaim the memory, i think it is kernel-side there
- 20150114.01:05:47 wim | nicm: nice! malloc_trim(0) works
- 20150114.01:11:55 freeroute | wim: are you running Linux? How did you get it working? Just add to source code?
- 20150114.01:12:12 wim | freeroute: yes and yes
- 20150114.01:12:35 wim | in grid_destroy()
- 20150114.01:12:35 wim | free(gd);
- 20150114.01:12:35 wim | malloc_trim(0);
- 20150114.01:12:45 wim | add it under the last free
- 20150114.01:14:41 wim | would be nice if it got into the code though :/
- ================================================================================================================================
- So basically, in tmux/grid.c - you want it to look like this:
- /* Destroy grid. */
- void
- grid_destroy(struct grid *gd)
- {
- struct grid_line *gl;
- u_int yy;
- for (yy = 0; yy < gd->hsize + gd->sy; yy++) {
- gl = &gd->linedata[yy];
- free(gl->celldata);
- }
- free(gd->linedata);
- free(gd);
- malloc_trim(0);
- }
improvement
Posted by Anonymous on Wed 14th Jan 2015 00:31
raw | new post
view followups (newest first): improvement? by Anonymous
Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.