Skip to content

Memory leak with futures #880

@HadrienRenaud

Description

@HadrienRenaud

It seems that creating and accessing a future create some non reachable objects.

Minimal example

Tested on branch development at a98629f.

With the following example, the usage of memory explodes, and quickly fills all the memory available (more than 16GB).

active class A
  def foo(): int
    1
  end
end

active class Main
  def main() : unit
    val a = new A
    val n = 10000000
    repeat i <- n do
      get(a!foo())
    end
  end
end

For an example with memory usage display, you can use this gist. This behavior does not happen with local objects (ie without futures).

First analysis

We suspect that this behaviour is due to some poor garbage collection while doing the get. Precisely, at runtime, the encore.c function actor_save_context that is used by get while blocking the actor, creates a context with pop_context (which internally calls malloc) and this context does not seem to be properly handled.

Valgrind summary:

==32075== LEAK SUMMARY:                                                         
==32075==    definitely lost: 3,776 bytes in 4 blocks                           
==32075==    indirectly lost: 102,400 bytes in 1 blocks                         
==32075==      possibly lost: 307,200 bytes in 3 blocks                         
==32075==    still reachable: 9,827 bytes in 9 blocks                           
==32075==         suppressed: 0 bytes in 0 blocks 

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