Opened 6 years ago

Closed 6 years ago

Last modified 6 years ago

#10630 closed Bug Report - General (Fixed)

Memory leak when subtitles are "on"

Reported by: Mossy <nosepam-mythtv@…> Owned by: stichnot
Priority: minor Milestone: 0.25.1
Component: MythTV - Captions Version: 0.25-fixes
Severity: medium Keywords: subtitles memory leak
Cc: Ticket locked: no


Most of the channels that I get ignore the "Subtitles Font" setting (which is fine by me). However, I get memory leaks on the channels that do use the "Subtitles Font", specified on the "Playback OSD" screen, when the subtitles are on.

The memory used by the FE increases until the FE becomes unusable. On some programmes this can happen in less than an hour on a machine with 4GB of ram. Happens with both LiveTV and Recordings. Stopping playback (i.e. going back to the main menu) does not free up the memory.

Also seen in 0.24.

To reproduce:

  1. Watch a channel that sets the subtitle font according to the setting on the "Playback OSD" page (or watch a recording made on such a channel).
  2. Turn the subtitles on, if they are not already on.
  3. Observe the FE memory usage (e.g. "top")

Expected results: FE memory usage does not increase significantly while the programme is being watched/played back.

Actual Results: FE memory usage increases proportionally to the amount of subtitles shown on screen until all available memory is used up. Stopping playback back does not free up memory.

Attachments (4)

version.txt (730 bytes) - added by Mossy <nosepam-mythtv@…> 6 years ago.
mythfrontend.log (11.8 KB) - added by Mossy <nosepam-mythtv@…> 6 years ago.
FE log (462.2 KB) - added by Mossy <nosepam-mythtv@…> 6 years ago.
valgrind log
10630.patch (671 bytes) - added by Mossy <nosepam-mythtv@…> 6 years ago.
Patch. Based on 0.25-fixes.

Download all attachments as: .zip

Change History (11)

Changed 6 years ago by Mossy <nosepam-mythtv@…>


Changed 6 years ago by Mossy <nosepam-mythtv@…>

FE log

Changed 6 years ago by Mossy <nosepam-mythtv@…>

valgrind log

comment:1 Changed 6 years ago by Mossy <nosepam-mythtv@…>

FE launched like this:

valgrind --log-file=/home/mossy/log/vglog.log --leak-check=full --error-limit=no --show-reachable=yes /usr/bin/mythfrontend -O UIPainter=qt

I played a 40 minute recording, subtitles "on", then let the FE idle for about 9 hours before shutting it down again.

comment:2 Changed 6 years ago by Mossy <nosepam-mythtv@…>

In case it helps this is a short recording from one of the relevant channels (5 mins, 100MB):

comment:3 Changed 6 years ago by stichnot

  • Milestone changed from unknown to 0.26
  • Status changed from new to accepted

I'm surprised at the memory leak, as it appears that the teletextscreen.cpp code is correctly cleaning up after itself, yet I see the mythfrontend memory size grow as I play the sample several times.

I am planning to refactor the teletextscreen.cpp and subtitlescreen.cpp into a common code base, and I expect that will fix the leak.

Changed 6 years ago by Mossy <nosepam-mythtv@…>

Patch. Based on 0.25-fixes.

comment:4 Changed 6 years ago by Mossy <nosepam-mythtv@…>

The memory leak was from objects that are stored in teletextscreen.cpp in a hash.

TeletextScreen::ClearScreen?() processed the hash as if it were a list, resulting in few, if any, of the objects being deleted.

The patch above fixes this.

I should have spotted the problem when I first looked at the code, your comment prompted me to look again.

comment:5 Changed 6 years ago by stuartm

Hah! You spotted this at exactly the same time I did, I was about to commit the fix.

comment:6 Changed 6 years ago by stuartm

  • Milestone changed from 0.26 to 0.25.1
  • Resolution set to Fixed
  • Status changed from accepted to closed

[master dc63336] Fix leak in TeletextScreen::ClearScreen?. Fixes #10630

comment:7 Changed 6 years ago by stuartm

[fixes/0.25 c171fe9] Fix leak in TeletextScreen::ClearScreen?. Fixes #10630 (cherry picked from commit d5b6760f1cf3a6eb031c96a7b340fbcbd1bb2358)

Add Comment

Modify Ticket

as closed The owner will remain stichnot.
The resolution will be deleted. Next status will be 'new'.

E-mail address and user name can be saved in the Preferences.

Note: See TracTickets for help on using tickets.