Help with handbrake with leaking memory.

Discussion in 'Apple TV and Home Theater' started by thunderboltspro, Jan 27, 2012.

  1. macrumors regular

    Joined:
    Oct 4, 2009
    Location:
    Midwest
    #1
    Been using handbrake for awhile now but once i've upgraded to lion, i've been having issues with my system running out of memory, (8 gigs). its leaking from inactive memory.
    I searched the web and couldn't find anything about it except this but doesn't lead me to an answer
    https://forum.handbrake.fr/viewtopic.php?f=12&t=21955&p=100821&hilit=lion+and+memory#p100821

    Something to do with lion disk caching but I still can't find a solution to the problem.

    Help help pretty please!!!!
     
  2. macrumors 65816

    Sedulous

    Joined:
    Dec 10, 2002
    #2
    Disappointing. I bought OS 10.7 recently (have not upgraded yet). Seems like Handbrake hasn't been updated in a while. Maybe they are working on a fix if someone pointed out the bug.
     
  3. macrumors regular

    Joined:
    Aug 24, 2009
    #3
    Try a nightly build. They are updated almost daily, but there is an increased risk of bugs existing.
     
  4. thread starter macrumors regular

    Joined:
    Oct 4, 2009
    Location:
    Midwest
    #4
    Night build 720 is a nope. Is their something in lion i can turn off that wont make handbrake do this?
     
  5. macrumors 68020

    Joined:
    Mar 27, 2003
    #5
    ITs possible that spotlight or time machine is trying to index your encode in progress ....

    I run hb svn head daily on an mbp with only 4 GB of ram running lion and have no issues with memory leakage. I would suggest its another process actually using the memory.

    .. and as said above .. use the latest nightly, it actually more stable than 0.9.5.
     
  6. macrumors 65816

    Sedulous

    Joined:
    Dec 10, 2002
    #6
    Apple definitely changed the way spotlight indexes in Lion. It also seems like how a user installs Lion (clean vs. upgrade) makes a big difference in general. Again, I have not made the leap (I plan to once I finish a major project).

    Maybe the OP could try to fix permissions (use Disk Utility) and see if that helps? I have heard that helps with various performance issues.
     
  7. thread starter macrumors regular

    Joined:
    Oct 4, 2009
    Location:
    Midwest
    #7

    Repaired both disc permissions and disk.
    Downloaded tinker tool systems and played around with application related catches.

    Did a fresh install of lion when it came out on mbp and used migration from a time machine back up for my apps and settings. Acquired a mac mini server and migrated my settings and apps on to it.

    Tomorrow I will try a fresh install of lion on my laptop and not install anything extra except handbrake and sees if that fixes it or somewhere on my time machine backup has gone funky.
     
  8. macrumors 65816

    Sedulous

    Joined:
    Dec 10, 2002
    #8
    I have no idea if it will help but if you are up for it, might as well try. Just strange that some people noted no Handbrake memory leak in Lion... so that is why I suggested maybe it is a bug unique to your Lion installation. Hope it works.
     
  9. macrumors 604

    chrono1081

    Joined:
    Jan 26, 2008
    Location:
    Isla Nublar
    #9
    If its a real memory leak this won't do anything. A memory leak is caused when a programmer is allocating memory on the heap and never deallocates it. The most you can do is try a nightly build or submit a bug report to the makers of handbrake.
     
  10. thread starter macrumors regular

    Joined:
    Oct 4, 2009
    Location:
    Midwest
    #10
    Reinstall of lion did nothing new, oh well i guess i'llkeep playing with the night builds and hope it gets fixed.
     
  11. Skoopman, Jun 2, 2012
    Last edited: Jun 2, 2012

    macrumors 6502

    Joined:
    Sep 24, 2011
    #11
    Did somebody find a solution? I just started using Handbrake to convert some MKV to MP4 and the memory leak is driving me nuts. I can't just turn of spotlight every time I want to encode something.

    Edit: Just tried out iFFmpeg, the inactive memory increases, too. The problem seems to be ffmpeg. I tried 0.102 and 0.11, both leak memory.
     
  12. macrumors 68020

    Joined:
    Mar 27, 2003
    #12
    you are aware that handbrake uses the libav fork of ffmpeg not ffmpeg ?

    btw, I run hb 0.9.6 and nightlies daily on a lion install and have not observed said mem leak.
     
  13. macrumors 6502a

    ljonesj

    Joined:
    Oct 20, 2009
    Location:
    Kingsport TN
    #13
    and try this turn off spotlight if your encoding to a external drive i only have spotlight for my itunes firewire drive and my main system drive as those are the ones i have hard time finding stuff a lot of times
     
  14. macrumors 65816

    Joined:
    Jan 1, 2008
    #14
    Inactive memory is essentially free memory that nothing wants yet.

    Apart from what you see in Activity Monitor (or whatever), what are the symptoms? What's crashing/failing/not working?

    A.
     
  15. macrumors 6502

    Joined:
    Sep 24, 2011
    #15
    I don't encode to an external drive, but to the same hard disk in the Mini.

    The problem is that the paging out is slowing down the mini. I had nearly 50% page outs compared to page ins. What happens after the encoding: If I delete the original MKV file and trash it, the memory is released. But what if I don't want to trash the file? I talked to the developer of iFFmpeg and we couln't find a solution. He thinks that OS X has some difficulty to release writing permissions to files. I might have to install Lion again.:(
     
  16. macrumors 65816

    Joined:
    Jan 1, 2008
    #16
    What happens if you go to a Terminal window and type 'purge' instead of trashing the file after an encode?

    A.
     
  17. macrumors 6502

    Joined:
    Sep 24, 2011
    #17
    The inactive RAM is released. But I can't use purge every time. If I want to encode let's say 10 movies over night, the RAM will get full after one movie and will page the hell out. Anyway, I will get a Time Capsule this week, move my files there and install Lion again.
     
  18. macrumors 68000

    Joined:
    Sep 24, 2008
    Location:
    Boon Docks USA
    #18
    Write to another disc (scratch disk). Makes a difference. When your reading and writing to the same disk, your encode speed will suffer. Reading from one disc and writing to another does help out allot. When your paging out, thats time reading and writing to the same disk again. BTW, how full is your hard drive?
     
  19. macrumors newbie

    Joined:
    Jun 24, 2012
    #19
    May not be a Lion problem

    I don't believe this has anything to do with Lion. I am still using Snow Leopard on my IMac and MacBookPro and within the last month or so my IMac system will flicker then freeze when using HandBrake and simultaneously watching another video. Oddly enough, the audio continues to play after the display has frozen but all system control and input is lost. I have to force a power off to regain use of the system. It also freezes shortly after the screen saver is activated when using HandBrake with no other software in use. I have this problem whether I'm using the internal harddrive or external USB drive. I checked Activity Monitor with only HandBrake running and noted that HandBrake is showing 197% CPU usage. I thought it might be due to a possible recent update to HandBrake so I reverted to using the 2008 (.9.3.0) version and the problem still occurs. I have all of the same software on my MacBookPro but have never encountered the problem on that system. I've tested the MacBookPro with all of the same files.
     
  20. jig1056, Nov 4, 2012
    Last edited: Nov 4, 2012

    macrumors newbie

    Joined:
    Nov 23, 2010
    #20
    Free up the inactive memory using a Bash script

    I'm running Mountain Lion and I'm having the exact problem. Doesn't seem to be a Lion issue, it's an issue with Handbrake. Also this is a clean install of Mountain Lion , it was not upgraded from Lion. As mentioned in a previous post running the purge command in terminal frees up the inactive memory and allows Handbreak to work as expected. And of course you can't sit at your machine and keep manually running the command so I wrote a quick and dirty Bash script to purge the inactive memory.

    This script polls the inactive memory and and runs the purge command if it goes above 1000 MB. It checks the memory every 5 mins. This is a very simple script but it does exactly what we need it to do. Time permitting I'll incorporate it into an automator script that will allow you to run it by clicking on it from your desktop.

    Here is link to the actual UNIX script.
    https://skydrive.live.com/redir?resid=A991234288FA5D84!258&authkey=!ANk9T9saentqYow

    For our UNIX newbies do the following: :D
    1) Save it to your harddrive
    2) Open up terminal and navigate to the folder where you saved the file
    3) Change the permission on the file, for ease of use use 777 "chmod 777 freemem.sh"
    4) run the script using using the following syntax "sh freemem.sh"

    **Note I have 16GB of memory, a threshold of 1000MB works for me but you may have to adjust for your machine.

    Code:
    
    #!/bin/bash
    
    mem_threshold=1000
    
    while [ 1 -le 2 ]
    do	
         #Get the current value for the inactive memory
         mem=$(top -l 1 | grep PhysMem: | awk '{print $6}')
         mem_inactive=`expr $mem |cut -f 1 -d'M'`
    	
    	#If the inactive memory is greater than memory threshold purge the memory
    	if [[ "$mem_inactive" -gt "$mem_threshold" ]]; then	
    		echo "**************************"
    		echo "Time $(date)"
      		echo "Threshold = $mem_threshold"    
      		echo "Inactive  = $mem_inactive" 
      		purge
      		echo "Memory purged"
      		echo " " 
    	fi  
    
      	sleep 300  #In seconds 
    done
    
     

Share This Page