Skip to content

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

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?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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