Opened 10 years ago

Closed 10 years ago

#1085 closed bug (fixed (in master))

Large memory leak in gtk client

Reported by: widget-angband@… Owned by:
Milestone: 3.1.2 beta Keywords: gtk blocker
Cc:

Description

Anecdotally I have personally noticed the gtk client slowing down after a long session of playing. I checked memory usage today and found the following values over time for RSS and VSZ in linux for a recent nightly:

/bin/ps -C angband -o rss=,vsz=
78548 211004
82028 251536
82136 251536
95848 265164
95956 265164
95956 265164

That's 20MB increase over less than 15m of playing. I suspect the hooks in main-gtk.c cause this as they all allocate new GtkTextBuffers? to xd->buf (xrta_win_data p*) whenever they are called, and nothing is cleaning them up.

The pointer in xd->buf in the handle_mons_list() function changes in the following way:

xd->buf was (nil), now 0x1316a00
xd->buf was 0x1316a00, now 0x1541340
xd->buf was 0x1541340, now 0x1e68b30
xd->buf was 0x1e68b30, now 0x209d110
xd->buf was 0x209d110, now 0x21b50b0
xd->buf was 0x21b50b0, now 0x21b51b0
xd->buf was 0x21b51b0, now 0x21b5230
xd->buf was 0x21b5230, now 0x21b52b0
xd->buf was 0x21b52b0, now 0x21b5330
xd->buf was 0x21b5330, now 0x21b55b0
xd->buf was 0x21b55b0, now 0x21b5630
xd->buf was 0x21b5630, now 0x21b56b0
xd->buf was 0x21b56b0, now 0x21b5730
xd->buf was 0x21b5730, now 0x23c8830
xd->buf was 0x23c8830, now 0x23c88b0
xd->buf was 0x23c88b0, now 0x23c8930
xd->buf was 0x23c8930, now 0x23c8db0
xd->buf was 0x23c8db0, now 0x23c8eb0
xd->buf was 0x23c8eb0, now 0x24d5810
xd->buf was 0x24d5810, now 0x24d5890
xd->buf was 0x24d5890, now 0x24d5910
xd->buf was 0x24d5910, now 0x24d5990
xd->buf was 0x24d5990, now 0x24d5a10
xd->buf was 0x24d5a10, now 0x25dc8b0

which I think supports this hypothesis. I'd be happy to examine this bug further but I'd need some help with the angband engine parts. I also need to understand the gtk code some more.

Attachments (1)

gtk-memory-leak.patch (1.5 KB) - added by widget-angband@… 10 years ago.
Tentative patch to remove a lot of the memory leak

Download all attachments as: .zip

Change History (4)

Changed 10 years ago by widget-angband@…

Tentative patch to remove a lot of the memory leak

comment:1 Changed 10 years ago by widget-angband@…

Have come up with a test patch which certainly reduces ongoing memory consumption but doesn't halt it. Certainly drops it by some orders of magnitude though. Stops re-allocation of GtkTextBuffers? over each other all the time.

comment:2 Changed 10 years ago by takkaria

  • Keywords blocker added
  • Milestone changed from Triage to 3.1.2 beta

comment:3 Changed 10 years ago by takkaria

  • Resolution set to fixed
  • Status changed from new to closed

[d6b2bf1] (SVN r1910)

Note: See TracTickets for help on using tickets.