Skip to content

When filtering / enumerating the objects that don't match the predicate are not released #17

@beloso

Description

@beloso

I am trying to enumerate a database finding only the values that match a given predicate.

Here is my code:

        NSPredicate *predicate = [NSPredicate predicateWithFormat:@"ANY SELF.names BEGINSWITH[cd] %@", searchText];
        @autoreleasepool {
            [self.datastore enumerateKeysAndObjectsBackward:NO
                                                     lazily:NO
                                              startingAtKey:nil
                                        filteredByPredicate:predicate
                                                  andPrefix:nil
                                                 usingBlock:^(LevelDBKey *key, id value, BOOL *stop){
                                                         [self.searchResults addObject:value];
                                                 }];
        }
        [[NSOperationQueue mainQueue] addOperationWithBlock:^{
            [self.searchDisplayController.searchResultsTableView reloadData];
        }];

The thing is that while enumerating Objective-LevelDB keeps all values in memory, even the ones that don't match the predicate. Not even lazy evaluation solves the issue here.

Am I doing something wrong? Can something be done to improve on memory usage?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions