question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[Bug] Possibile memory leak in save

See original GitHub issue

I have found a possibile memory leak in the ffmpeg adapter in spleeter_utils/audio/ffmpeg.py, when calling to save:

process = subprocess.Popen(
            command,
            stdout=open(os.devnull, 'wb'),
            stdin=subprocess.PIPE,
            stderr=subprocess.PIPE)
        
        # Write data to STDIN.
        try:
            process.stdin.write(data.astype('<f4').tostring())
        except IOError:
            raise IOError(f'FFMPEG error: {process.stderr.read()}')
        
        # Clean process.
        process.stdin.close()
        if process.stderr is not None:
            process.stderr.close()
        process.wait()

        get_logger().info('File %s written', path)
        
        ################################################################
        current_mem, peak_mem = tracemalloc.get_traced_memory()
        overhead = tracemalloc.get_tracemalloc_memory()
        summary = "traced memory: %d KiB  peak: %d KiB  overhead: %d KiB" % (
            int(current_mem // 1024), int(peak_mem // 1024), int(overhead // 1024)
        )
        print( "after save", summary )
        ################################################################

After consecutive calls the memory will not be de-allocated, and it consists of the whole block of the input file (~30MB each time):

before save traced memory: 31558 KiB  peak: 32248 KiB  overhead: 30933 KiB
after save traced memory: 31560 KiB  peak: 32946 KiB  overhead: 30935 KiB
before save traced memory: 63630 KiB  peak: 64324 KiB  overhead: 58610 KiB
after save traced memory: 63632 KiB  peak: 65018 KiB  overhead: 58611 KiB

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:4
  • Comments:15

github_iconTop GitHub Comments

3reactions
amirkhn33commented, Jun 6, 2021

I’m still facing this memory leak issue. Also, the workaround results in an error Do not use tf.reset_default_graph() to clear nested graphs. If you need a cleared graph, exit the nesting and create a new graph. tensorflow==2.3 spleeter==2.2.2

@mmoussallam can you help me out with this?

2reactions
mmoussallamcommented, Oct 19, 2020

This bug should be fixed now that we’ve moved on to TF 2

Read more comments on GitHub >

github_iconTop Results From Across the Web

Find and fix Memory Leaks in Windows 10 - YouTube
A Memory Leak is a misplacement of resources in a computer program due to faulty memory allocation. It happens when a RAM location...
Read more >
Any news on the memory leak save bloat/crash bug? - Reddit
Try loading your saves, one at a time, from in-game. If one loads, that particular save isn't corrupted but something nearby might be...
Read more >
How To Detect and Prevent Memory Leaks | Scout APM Blog
Leaks waste space by filling up pages of memory with inaccessible data and waste time due to extra paging activity. Leaked memory eventually ......
Read more >
Possible memory leak? - Bugs reports - GDevelop Forum
I used two nested repeat loops to create a million variables. When loading the debugger, GDevelop crashed saying there was some limit of...
Read more >
How to fix memory leaks Monterey - Setapp
So it's quite critical you solve the issue as fast as possible. ... How do you tell a memory leak bug from a...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found