Skip to content

Increase Server Memory When Client program repeats ActorSelection and Terminated #3430

@iris4865

Description

@iris4865

Akka version: 1.3.6
Akka.Remote: 1.3.6 (with DotNetty 0.4.6)
Platform: .Net Framework 4.7
Project link: https://github.com/iris4865/IssueStorages/tree/master/AkkaRemote_1.3.6/ActorSelection

Server memory usage has increased When Client program connects and disconnects. At the start of the program, the memory was 35.85MB. ActorSelection test result increased to 1.88GB. I did profiling with JetBrains DotMemory 2018.1. I think that Dotnetty.Buffers is not garbage collected.

  1. Start Server program with Akka.Remote.
  2. Client program connects to Server through Akka.Remote.
  3. Client program sends the message to Server.
  4. Server program reply to the Client program after processing the message.
  5. Client program prints the result and exit.
  6. Multiple clients repeat 2~5.
  7. Memory usage has increased.

image

  • server code
namespace AkkaSelectionNettyEnvServer
{
    class Program
    {
        static void Main(string[] args)
        {
            ActorSystem system = ActorSystem.Create("Server");

            system.ActorOf(Props.Create(() => new HelloActor()), "HelloActor");

            system.WhenTerminated.Wait();
        }
    }

    public class HelloActor : ReceiveActor
    {
        public HelloActor()
        {
            Receive<string>(value =>
            {
                Console.WriteLine(value);
            });
        }
    }
}
  • client code
namespace AkkaSelectionNettyEnvClient
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {

                ActorSystem system = ActorSystem.Create("Client");

                var actor = system.ActorSelection("akka.tcp://Server@192.168.100.99:8083/user/HelloActor")
                    .ResolveOne(TimeSpan.FromSeconds(10))
                    .Result;

                actor.Tell("Hello");

                system.Terminate();
            }
            catch(Exception)
            {

            }
        }
    }
}
  • client executer code
    class Program
    {
        static void Main(string[] args)
        {
            if (args.Length == 0)
                ExecuteLoop("AkkaSelectionNettyEnvClient.exe");
            else
                ExecuteLoop(args[0]);
        }

        public static void ExecuteLoop(string filename)
        {
            ProcessStartInfo info = new ProcessStartInfo()
            {
                FileName = filename,
                CreateNoWindow = true,
                WindowStyle = ProcessWindowStyle.Hidden,
            };
            while (true)
            {
                List<Process> pList = new List<Process>
                {
                    Process.Start(info),
                };

                foreach (var p in pList)
                {
                    p.WaitForExit();
                    p.Dispose();
                }

                pList = null;
            }
        }
    }

p.s
I think Akka version 1.1.3 (with Akka.Remote 1.1.3 and Helios 2.1.2) is no problem.
so I am using version 1.1.3 temporarily.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions