Skip to content

Memory leak in unbounded async "stack" #9

@pauldraper

Description

@pauldraper

From discussion opentracing/specification#23 (comment)

void main(ExecutorService executor) {
  executor.submit(new Runnable {
    public void run() {
      Thread.sleep(1);
      main(executor);
    }
  })
}

// okay
main(Executors.newSingleTheadExecutor());
// memory leak
main(SpanPropagatingExecutors.newSingleThreadExecutor(DefaultSpanManager.getInstance));

I'd prefer to keep the "stack tracking" on the actual stack, not LinkedSpanContexts.

I suggest simplifying the interface to.

public interface SpanManager {
  Span currentSpan();
  void execute(Span span, Runnable f);
  void <T> execute(Span span, Callable<T> f);
}```

This will allow the context to get reset after the code of interest is done, but it's impossible to have a memory leak (at least, not without having stack overflow).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions