                     dispatch_semaphore_wait(lock, DISPATCH_TIME_FOREVER)
                     do {
                         if pending {
-                            // Free up memory
-                            values.removeAll(keepCapacity: false)
                             promise.reject(error)
                             pending = false
+                            values.removeAll(keepCapacity: false)
                         }
                     }
                     dispatch_semaphore_signal(lock)

                }

                self.fulfillCallbacks.removeAll(keepCapacity: false)
            }
        }
        dispatch_semaphore_signal(self.mutex)

                            if values.count == promises.count {
                                promise.fulfill(values)
                                pending = false
                                values.removeAll(keepCapacity: false)
                            }
                        }
                    }
