UPGRADE YOUR SKILLS: Learn advanced Swift and SwiftUI on Hacking with Swift+! >>

LazyVGrid Memory Leak?

Forums > SwiftUI

I just built an experimental project in Xcode 12 BETA and inspected with Instruments. It indicated that there are about 3,000 memory leaks found. Is this possibly a LazyVGrid bug? Most "Leaked Object" that shown in Instruments are SwiftUI.LayoutComputer.EngineDelegate.

Update: Now Instruments indicated that there are 30,000 memory leaks. Most of them seems to be Swift._ContiguousArrayStorage. I have no idea now.

5      

I've experienced the same thing with Xcode 12b. I'm using ScrollView, TextField, ColorPicker (and of course Button & VStacks, HStacks, ZStacks). From Instruments, I can see over 20,000 leaks totalling to roughly 2.3MB. My app ends up consuming somwhere between 50-100MB of RAM.

I have also seen Swift.ContiguousArrayStorage in many of these leaks. Plus other Mallocs related to other SwiftUI components.

I have tried to use the sage wisdom of unowned and weak variables however it doesn't seem to work in a framework that is inherently built around structs not classes. The compiler doesn't let me use weak and unowned in most of the code that I try to fix.

I hope this is a bug (given that it's beta Xcode I think maybe this is the case) and that it will be solved soon.

2      

Is someone else still experiencing this bug?

I am displaying a list of images in my app and i can see about 17000 leaks. My app also consumes about 100 MB of RAM.

The most leaked objects are:

  • Swift.ContigousArrayStorage
  • SwiftUI.(TypedElement)
  • SwiftUI.LayoutComputer.Engine

The resposible lib for more or less all of the leaks is libswiftCore.dylib.

I am using XCode 12.2 on Mac OS Big Sur.

I have no idea how to fix this. Does anyone has an idea how to tackle this problem?

2      

Hacking with Swift is sponsored by Essential Developer

SPONSORED Join a FREE crash course for mid/senior iOS devs who want to achieve an expert level of technical and practical skills – it’s the fast track to being a complete senior developer! Hurry up because it'll be available only until April 28th.

Click to save your free spot now

Sponsor Hacking with Swift and reach the world's largest Swift community!

Archived topic

This topic has been closed due to inactivity, so you can't reply. Please create a new topic if you need to.

All interactions here are governed by our code of conduct.

 
Unknown user

You are not logged in

Log in or create account
 

Link copied to your pasteboard.