GPUImage2 icon indicating copy to clipboard operation
GPUImage2 copied to clipboard

Memory leaking - From 70 MB to 700MB, and never releases it

Open ricardomartinlabs opened this issue 6 years ago • 8 comments

Hello. First of all, I would like to thank the author for this library. It's very intuitive and I consider it much better than CoreImage.

I'm developing a camera app, but I'm facing a huge memory leak. The memory goes from 100 MB to 700MB in matter of seconds, and I have no idea why. Even after I close my controller or release the images, the memory is not release, it only grows more and more.

screen shot 2017-07-27 at 11 24 52

screen shot 2017-07-27 at 11 26 55

How can I fix this problem? I don't understand how memory is leaking, I don't know where all this malloc is coming from :(

ricardomartinlabs avatar Jul 27 '17 14:07 ricardomartinlabs

To begin to debug this, what are you doing when the memory is increasing? What specific actions are you taking that use the framework?

BradLarson avatar Jul 27 '17 15:07 BradLarson

Hello! The memory is drastically increased when I execute this method a few times (it's not a live feed, I just apply filter to 6 images). The input image was created using CoreImage. May be there is a correlation? I believe I might be doing something wrong, but I'm unable to check where and why

func getFilter(_ imageParam: UIImage) -> UIImage? {
        var uiimage = imageParam
        
        if  let ciImage = uiimage.ciImage{
            let cgImage = cicontext.createCGImage(ciImage, from: ciImage.extent)
            uiimage = UIImage(cgImage: cgImage!)
        }
        
        let rgb = RGBAdjustment()
        rgb.red = 1.1
        rgb.green = 1.25
        rgb.blue = 1.74
        
        let levelAdjustment = LevelsAdjustment()
        levelAdjustment.minimum = Color(red: 21.0/255.0, green: 21.0/255.0, blue: 21.0/255.0)
        
        let filteredImage = uiimage.filterWithPipeline { (input, output) in
            input --> levelAdjustment --> rgb --> output
        }
        
        return filteredImage
        
    }

ricardomartinlabs avatar Jul 27 '17 16:07 ricardomartinlabs

I observed same behavior using the predecessor of GPUImage2, and looks like there is something similar here. In my case, I was applying a filter to static images few times and got huge memory allocation, and never deallocating.

klauslanza avatar Oct 07 '17 15:10 klauslanza

Hi all, I have faced the same problem. I'm applying filters to series of pictures and the memory is being increased drastically. Is there anyone who has found a solution for this situation?

ilkayaktas avatar Sep 16 '18 14:09 ilkayaktas

@ilkayaktas : I'm also facing the same kind of issue. Have you found the solution. How to deallocate the memory in this case.

smanojarun avatar Dec 24 '18 10:12 smanojarun

@smanojarun Unfortunately i gave up looking for a solution. I switched to CoreImage for image processing. It's better.

ilkayaktas avatar Dec 24 '18 20:12 ilkayaktas

Got it @ilkayaktas .Thanks.

smanojarun avatar Dec 25 '18 13:12 smanojarun

Anything new?

sh4wn avatar May 05 '19 13:05 sh4wn