Skip to content

Commit

Permalink
fixed memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
NickAger committed Jan 23, 2018
1 parent 2683a19 commit 77ba440
Showing 1 changed file with 10 additions and 7 deletions.
17 changes: 10 additions & 7 deletions framework/Source/Operations/HistogramEqualization.swift
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@ public class HistogramEqualization: OperationGroup {

({downsamplingFactor = 16})()

self.configureGroup{input, output in
self.rawDataOutput.dataAvailableCallback = {data in
self.configureGroup{[weak self] input, output in
guard let strongSelf = self else {
return
}
strongSelf.rawDataOutput.dataAvailableCallback = { data in
var redHistogramBin = [Int](repeating:0, count:256)
var greenHistogramBin = [Int](repeating:0, count:256)
var blueHistogramBin = [Int](repeating:0, count:256)
Expand All @@ -46,12 +49,12 @@ public class HistogramEqualization: OperationGroup {
equalizationLookupTable[(binIndex * 4) + 3] = 255
}

self.rawDataInput.uploadBytes(equalizationLookupTable, size:Size(width:256, height:1), pixelFormat:.rgba)
self?.rawDataInput.uploadBytes(equalizationLookupTable, size:Size(width:256, height:1), pixelFormat:.rgba)
}

input --> self.histogram --> self.rawDataOutput
input --> self.equalizationFilter --> output
self.rawDataInput --> self.equalizationFilter
input --> strongSelf.histogram --> strongSelf.rawDataOutput
input --> strongSelf.equalizationFilter --> output
strongSelf.rawDataInput --> strongSelf.equalizationFilter
}
}
}
}

0 comments on commit 77ba440

Please sign in to comment.