iOS App file size not reducing after deleting photos from core data

1.8k views Asked by At

I am testing an App that takes images from the iPhone Camera / Photos and saves them into the App to add various notes to. All is working fine with Core Data (adding and deleting etc.) as testing of closing and reopening app shows all is ok. However, the file size of the App when checked on iPhone Settings... Storage... does not reduce back down again.

E.g.

-Empty App size is 17mb

-Adding 6 photos increases App size to 29mb

-25 photos = 84mb

-But when I delete all but 5 photos from core data the file App file size is still about 69mb.

So the iPhone is updating the size of the apps straight away under 'settings...storage', but the App itself is still hoarding data related to the photos that have been deleted from Core Data with ...

"context.deleteObject"... and "context.save()"

I'm assuming data is held somewhere on the App about the original photos that were subsequently deleted.

Thus my question is how to remove this unwanted data that is no longer relevant to the App.?

1

There are 1 answers

3
Srlg On BEST ANSWER

I was having the same issue, but recording videos instead. After I recorded the video and uploaded to a server, I was deleting the videos, but the size of my Documents and Data continued to increase.

After looking what contained on my Documents and Data folder I found out that the problem was that the file on /AppData/Library/Cache/(package name)/Cache.db-wal that was increasing size. Mine it went from 24kb up to 6mb. But then, stabilized on that number. No matter how many videos I took, the size was not increasing anymore.

So you can try to figure out what is going on on your side downloading the Documents and Data content, and looking which files are increasing in size. You can download it following this instruction:

1 - in Xcode, choose Window > Devices.

2- select your device on the left.

3 - select your app from the Installed Apps list.

4- use the gear menu to either browse your app's container (Show Container) or download it to your Mac (Download Container) for offline analysis.