      */
     private func dequeueInput() {
         while !inputQueue.isEmpty {
-            let data = inputQueue[0]
-            var work = data
-            if let fragBuffer = fragBuffer {
-                var combine = NSData(data: fragBuffer) as Data
-                combine.append(data)
-                work = combine
-                self.fragBuffer = nil
-            }
-            let buffer = UnsafeRawPointer((work as NSData).bytes).assumingMemoryBound(to: UInt8.self)
-            let length = work.count
-            if !connected {
-                processTCPHandshake(buffer, bufferLen: length)
-            } else {
-                processRawMessagesInBuffer(buffer, bufferLen: length)
-            }
-            inputQueue = inputQueue.filter{ $0 != data }
+            autoreleasepool {
+                let data = inputQueue[0]
+                var work = data
+                if let fragBuffer = fragBuffer {
+                    var combine = NSData(data: fragBuffer) as Data
+                    combine.append(data)
+                    work = combine
+                    self.fragBuffer = nil
+                }
+                let buffer = UnsafeRawPointer((work as NSData).bytes).assumingMemoryBound(to: UInt8.self)
+                let length = work.count
+                if !connected {
+                    processTCPHandshake(buffer, bufferLen: length)
+                } else {
+                    processRawMessagesInBuffer(buffer, bufferLen: length)
+                }
+                inputQueue = inputQueue.filter{ $0 != data }
+            }
         }
     }
     

    /**
     Connect to the WebSocket server on a background thread.
     */
    public func connect() {
        guard !isConnecting else { return }
        didDisconnect = false
        isConnecting = true
        createHTTPRequest()
        isConnecting = false
    }
    
    /**

        let code = processHTTP(buffer, bufferLen: bufferLen)
        switch code {
        case 0:
            isConnecting = false
            connected = true
            guard canDispatch else {return}
            callbackQueue.async { [weak self] in
