Skip to content

Commit

Permalink
engine.main: fix memory leak due to latency histogram creation
Browse files Browse the repository at this point in the history
  • Loading branch information
eugeneia committed Nov 2, 2018
1 parent 8201d1d commit debd26c
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/core/app.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,14 @@ function timeline ()
return timeline_log
end

-- Breath latency histogram
local latency -- initialized on demand
function enable_latency_histogram ()
if latency == nil then
latency = histogram.create('engine/latency.histogram', 1e-6, 1e0)
end
end

-- The set of all active apps and links in the system, indexed by name.
app_table, link_table = {}, {}
-- Timeline events specific to app instances
Expand Down Expand Up @@ -529,10 +537,10 @@ function main (options)
-- Ensure timeline is created and initialized
timeline()

-- Enable latency histogram if requested
-- Enable latency histogram unless explicitly disabled
local breathe = breathe
if options.measure_latency or options.measure_latency == nil then
local latency = histogram.create('engine/latency.histogram', 1e-6, 1e0)
enable_latency_histogram()
breathe = latency:wrap_thunk(breathe, now)
end

Expand Down

0 comments on commit debd26c

Please sign in to comment.