Skip to content
This repository was archived by the owner on Jul 31, 2023. It is now read-only.
This repository was archived by the owner on Jul 31, 2023. It is now read-only.

Potential Memory Leak #168

@TylerPachal

Description

@TylerPachal

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:

Memory Usage
Processes

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:

  1. Either I am using this library incorrectly, or
  2. There is a memory leak somewhere that occurs under heavy usage caused by some piece slowing down.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions