-
Notifications
You must be signed in to change notification settings - Fork 39
Potential Memory Leak #168
Description
I have an Elixir project where I am using opencensus-erlang for the first time. I have a helper function for wrapping pieces of my code in spans:
def span(name, attributes, func) do
parent_span_ctx = :ocp.current_span_ctx()
new_span_ctx =
:oc_trace.start_span(name, parent_span_ctx, %{
:attributes => attributes
})
:ocp.with_span_ctx(new_span_ctx)
try do
func.()
after
:oc_trace.finish_span(new_span_ctx)
:ocp.with_span_ctx(parent_span_ctx)
end
end
To talk to my collector I am using the opencensus_service library.
In my application code, I have a layout that is something like this, with a parent span that has some children (which may have children themselves):
span("span_a", attributes, fn ->
span("span_b", attributes, fn ->
span("span_c", attributes, fn -> :ok end)
span("span_d", attributes, fn -> :ok end)
end)
end)
When running this code, my application runs out of memory very quickly, and the offending process is oc_reporter. I was able to replicate this locally and watch the memory usage with Observer. The memory usage is mainly binary:
I thought maybe that I am sending too much data, but after poking around in Observer I don't see the ETS tables growing unbounded or queues sizes increasing, so I don't think that is the cause. When running locally I had a Collector setup that was just writing to file. In production our Collector publishes to Kafka.
I also tried forcing some garbage collections and hibernating to see if there was any memory I could record that way, but that didn't help at all either.
I am now stuck and don't really know where to go from here:
- Either I am using this library incorrectly, or
- There is a memory leak somewhere that occurs under heavy usage caused by some piece slowing down.

