I want to demonstrate a large size image(5184*3456) in a modal sheet with swiftui.
When I popup the sheet, memory usage increases from 20mb up to 100mb. However, when I dismiss the sheet, memory usage just decreases from 100mb to 92mb, wear and tear. I popup the sheet again, memory usage increases from 92mb back to 100mb.
Back and forth, memory usage always changes between 92mb and 100mb, instead of between 20mb and 100mb that I expect to. Why doesn't memory usage decrease to 20mb when the sheet dismiss? Why doesn't image been purged from memory when the sheet dismisses? I just want memory usage stays in a low level. How could I do? Thanks in advance.
When I popup the sheet, memory usage increases from 20mb up to 100mb. However, when I dismiss the sheet, memory usage just decreases from 100mb to 92mb, wear and tear. I popup the sheet again, memory usage increases from 92mb back to 100mb.
Back and forth, memory usage always changes between 92mb and 100mb, instead of between 20mb and 100mb that I expect to. Why doesn't memory usage decrease to 20mb when the sheet dismiss? Why doesn't image been purged from memory when the sheet dismisses? I just want memory usage stays in a low level. How could I do? Thanks in advance.
Code Block struct IntroductionView: View { @Environment(\EnvironmentValues.presentationMode) var presentation var body: some View { GeometryReader{geo in VStack(alignment:.leading){ Image("image") .resizable() .aspectRatio(contentMode: .fill) .frame(maxHeight:geo.size.height/4) .clipped() Spacer() Button(action: { presentation.wrappedValue.dismiss() }, label: { Text("Close") } } } } }