Audacity Bug Summary
••• Introduction •••
••• Keywords •••
    Audacity 3.0.3 development began 19th April 2021

Audacity Bugzilla



Bug 822 - Memory leak and orphan block files when paste causes cutlines to disappear
Memory leak and orphan block files when paste causes cutlines to disappear
Status: RESOLVED FIXED
Product: Audacity
Classification: Unclassified
Component: Application Core
2.1.0
PC Other
: P4 Review
Assigned To: Default Assignee for New Bugs
: patch_closed
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2015-01-14 06:59 UTC by Paul L
Modified: 2018-08-20 11:45 UTC (History)
7 users (show)

See Also:
Steps To Reproduce:
Here is how to determine whether there is a leak of WaveClips in the VS 2013 debugger: Put breakpoints at the ends of these four functions: the two constructors of WaveClip, the destructor, and QuitAudacity(). Use the menu for "Hit Count" to stop when a multiple of 100 for the first three, so it does not interfere with usage. Do things with Audacity, then exit. Use the Breakpoints window to verify that the sum of the hit counts for the first two breakpoints equals that for the third. If the sum is greater, then at least one WaveClip and associated structures have leaked. Now do this to demonstrate a leak. 1) Turn on Cut Lines in Track preferences. 2) Generate 500 ms of noise. 3) Use selection toolbar to select from 300 ms to 400 ms, then Cut (ctrl-x) so there is a cutline. 4) Select from 0 to 100 ms and Copy. 5) Select all and Paste. Note that the cutline disappears. 6) Exit Audacity, saving the file. There is a memory leak of a cutline. 7) Restart Audacity and open the file. See the orphan blocks warning. Or instead of relying on breakpoints, do the above, but save the project. Exit Audacity, restart, and open the project again. You get an orphan blocks warning, indicating a resource leak somewhere.
Release Note:
First Git SHA:
Group: ---
Workaround:
Closed: 2018-08-20 00:00:00
petersampsonaudacity: Test‑OK‑Win+
petersampsonaudacity: Test‑OK‑Mac+


Attachments
Fixes bug 822, a memory leak when pasting into a wave track (457 bytes, patch)
2015-01-14 07:06 UTC, Paul L
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Paul L 2015-01-14 06:59:14 UTC

    
Comment 1 Paul L 2015-01-14 07:06:33 UTC
Created attachment 545 [details]
Fixes bug 822, a memory leak when pasting into a wave track
Comment 2 Gale Andrews 2015-01-14 14:44:37 UTC
Not sure of a rating. Reading from "a leak can happen" and "determine whether there is a leak", should this be called Moonphase? 

Do we mean a cut line (as turned on in Tracks Preferences) or split line or both?

Are the orphan block files also moonphase?
Comment 3 James Crook 2015-01-14 14:59:54 UTC
We have lots of memory leaks.  They are embarrassing.

They don't need release noting, so I'm setting this one to a P4.  The orphan block file can cause further problems, but the fact orphans can cause serious problems is not this bug and is reported elsewhere.
Comment 4 Paul L 2015-01-14 17:51:35 UTC
"Moonphase" means a bug that is intermittent?  But I think this bug would happen consistently following the steps.
Comment 5 Steve Daulton 2015-01-14 22:17:31 UTC
Testing on Linux (Debian).

Following the steps to reproduce, I don't get "an orphan blocks warning".
Comment 6 Steve Daulton 2015-01-14 22:23:11 UTC
(In reply to comment #5)
Steve wrote:
> Testing on Linux (Debian).
> 
> Following the steps to reproduce, I don't get "an orphan blocks warning".

Testing on Windows XP (virtual machine) I don't get orphan blocks warning.
Comment 7 Paul L 2015-01-14 22:45:13 UTC
Sorry, I amended steps to reproduce.  Do save before exiting.  Then restart and reopen the file.

Saving was not necessary to see the evidence of memory leak in the debugger, as I originally described this bug.
Comment 8 Bill Wharrie 2015-01-14 22:57:46 UTC
(In reply to comment #7)
Following the amended steps I get one orphan blockfile, using 2.1.0-alpha Jan 13 2105 on Mac OS X 10.9.4.
Comment 9 Steve Daulton 2015-01-14 23:05:50 UTC
(In reply to comment #7)
I see the error with the updated steps.

Could it be fixed by adding:

WX_CLEAR_ARRAY(cuts)

at line 736 in WaveTrack.cpp?
Comment 10 Paul L 2015-01-14 23:19:51 UTC
Yes, that, or the patch I supplied.  I did not know that macro and instead wrote the obvious delete loop.
Comment 11 Paul L 2015-01-15 19:32:50 UTC
Fixing the memory leak is easy.

But consider this.  Would it make sense to allow zero-length wave clips?  Then it would not be necessary to delete any cutlines.  New clips could be created so that cutlines, falling in the gap left by a paste shorter than selection, would not have to be orphaned.

More trouble than it is worth perhaps.
Comment 13 Peter Sampson 2017-11-09 09:10:41 UTC
(In reply to Paul L from comment #12)
Tested on 2.2.1 alpha Audacity2.2.1JC5Nov2017 and on the released 2.2.0

I neither case did I get orphans

Checked too on Mac with latest alpha and 2.2.0 - mo orphans there either.

So I will close this bug as RESOLVED