Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Memory Issue #39

Open
jsetting32 opened this issue Mar 3, 2017 · 1 comment
Open

Memory Issue #39

jsetting32 opened this issue Mar 3, 2017 · 1 comment

Comments

@jsetting32
Copy link

When fetching a directory's contents with about 40k items, my application jumps to about 500mb and crashes. Is there a more memory efficient way of doing this?

@jsetting32
Copy link
Author

jsetting32 commented Mar 3, 2017

I was able to resolve the issue and would like to make a branch and pull. All I did was add an autorelease block within processing of the data when the stream has ended.

` case NSStreamEventEndEncountered: {
NSUInteger offset = 0;
CFIndex parsedBytes;
uint8_t *bytes = (uint8_t *)[self.receivedData bytes];
NSUInteger totalbytes = [self.receivedData length];

        do {
            @autoreleasepool {
                CFDictionaryRef listingEntity = NULL;
                parsedBytes = CFFTPCreateParsedResourceListing(NULL, &bytes[offset], totalbytes - offset, &listingEntity);
                if (parsedBytes > 0) {
                    if (listingEntity != NULL) {
                        self.filesInfo = [self.filesInfo arrayByAddingObject:(__bridge_transfer NSDictionary *)listingEntity];
                    }
                    offset += parsedBytes;
                }
            }
        } while (parsedBytes > 0);
        
        [self.streamInfo streamComplete:self];
        break;
    }`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant