         // free the FFT setup
         vDSP_destroy_fftsetup(fftSetup)
         
+        // free the memory used to store the samples
+        samplesWindowed.destroy()
+        samplesWindowed.dealloc(length)
+        
         // free the window
         window.destroy()
         window.dealloc(length)

        // setup window
        window = UnsafeMutablePointer<Float>.alloc(length)
        windowType.createWindow(window, len: length)
        
        // half length (for buffer allocation)
        let halfLength = length / 2

        // get half length
        let halfLength = length / 2
        
        // prepare output
        var output = [Float](count: halfLength, repeatedValue: 0.0)
        
        // window the samples
        vDSP_vmul(samples, 1, window, 1, samplesWindowed, 1, UInt(length))
            
        // pack samples into complex values (use stride 2 to fill just reals
        vDSP_ctoz(UnsafePointer<DSPComplex>(samplesWindowed), 2, &complexBufferA, 1, UInt(halfLength))
            
        // perform FFT
        // TODO: potentially use vDSP_fftm_zrip
