App reporting inaccurate Usage / Storage
Asked Answered
J

1

28

One of my apps will, very occasionally, report its Storage (via Settings -> General -> Usage -> Storage) as 4GB when, in reality, the total size of all files in the app's Sandbox (Documents, Library, tmp) averages around 10MB or so.

I'm kind of at my wits end and wondering if anyone has experienced anything like this. I have a sneaking suspicion that it is something related to UIDocument, but can't be certain. It seems like too little to go on right now to file a radar.

In some instances the app will compel the system to present a dialog warning the user that the system is running low on storage. When this happens it seems the system reconciles the difference between the storage it thinks the app is using and reality and the storage numbers will then drop back down to 10MB or so.

It's really odd.

Any ideas on things I might look at would be appreciated.

The implementation of contentsForType:error:

- (id) contentsForType: (NSString *) inTypeName
    error: (NSError **) outError
{
    NSFileWrapper       *newWrapper, *audioFileWrapper;
    NSString            *audioFilename;
    NSURL               *newAudioWrapperURL;

    newWrapper = [[[NSFileWrapper alloc] initDirectoryWithFileWrappers: nil] autorelease];

    // add updated info
    [newWrapper addRegularFileWithContents: [NSKeyedArchiver archivedDataWithRootObject: self.testInfo] preferredFilename: QSDocumentInfoKey];

    // scan audio files and clean up where needed
    for (NSDictionary *wordInfo in self.wordInfoList) {
        if ((audioFilename = [wordInfo objectForKey: QSInfoAudioKey]) != nil) {
            newAudioWrapperURL = [self.fileURL URLByAppendingPathComponent: audioFilename];
            if ([[NSFileManager defaultManager] fileExistsAtPath: [newAudioWrapperURL path]]) {
                audioFileWrapper = [[[NSFileWrapper alloc] initWithURL: newAudioWrapperURL options: 0 error: nil] autorelease];
                [newWrapper addFileWrapper: audioFileWrapper];
            }
        }
    }

    self.fileWrapper = newWrapper;

    return self.fileWrapper;
}
Jala answered 27/1, 2012 at 18:57 Comment(9)
How are you storing your app's data?Stylobate
What does you app do (don't need specifics)? Do you cash anything? Download anything. Any reason something may go wrong an an array or some other thing that you write down get very big? Does it happen on the simulator too?Scrag
Saving files via UIDocument using NSFileWrapper. Another peculiar thing: I don't even have to been saving anything for this to happen. The last attempt to store information may have been hours or a day ago and this will just randomly happen.Jala
Also, I'm not caching or downloading anything. The document is a dictionary and a subdirectory of containing audio files. Again I've gone through and checked all the file sizes and Settings will say 4GB (which is a suspicious number very close to 2^32, no?) while my calculations will say 10MB, 12MB, whatever. Also, seen it in the simulator as it won't show you Storage info in settings.Jala
Can you post some code of how you saving stuff to files? are you doing it in some kind of loop that maybe is running too many times?Dunkin
Updated question with implementation of contentsForType:error:Jala
I've seen this a few times when using the TestFlight system for distributing evaluation iOS 5 apps to testers. Removing it fixed the problem.Humbug
This is interesting, because we're using it TestFlight as well. And might explain why we've not heard reports of this problem from users of the released versions. Thanks!Jala
You are doing a right thing because Apps should have security options in it because the App what you develop should not affect the tablets or Android phonesPhilender
V
1

I've seen this with the TestFlight SDK. Removing the usage of TestFlight should resolve this problem.

Virility answered 20/2, 2012 at 17:43 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.