c# - .NET Remoting Singleton memory leak, TCP, Marshal by Reference -


I am using the simplest example of remoting which I can get, a window service and a Windows form program Sharing the middle item (client), running on the same machine.

The service instantates the object in this way:

  serviceConfigRemote = new serviceContentDataTermot (); ServerChannel = new TcpServerChannel (9 090); ChannelServices.RegisterChannel (server channel, incorrect); Remoting Services Marshall (this. ServiceConfigRemote, "ServiceConfigData");  

The client establishes a connection like this:

  TcpClientChannel channel = new TcpClientChannel (); ChannelServices.RegisterChannel (channel, incorrect); ConfigData = (serviceConfigDataRemote) Activator.GetObject (typef (serviceConfigDataRemote), "tcp: // localhost: 9090 / service configuration data");  

This idea is for service to change some parameters of the object, because the client is able to read those changes.

The object is itself:

Public Seal Class Service Confidentiality: Martial Biriff Objet {Private Bull My Connected Flag; Private Bull mySendingFlag; Private Bull MyUpdate Flag; Private string myClientConfiguration; Static Redondoine Services Configurable Display Example = New ServiceContentDateArt (); Fixed service configurationDate () {} public service config.datemote () {myConnectedFlag = false; MySendingFlag = false; MyUpdateFlag = false; MyClientConfiguration = ""; } Public Stable Service ConfidentPromot Instance {Receive {frequency example; }} Start Public Override Object Lifetime Service () {Return (empty); } Public Bull Linked {get {myconnectedflag; } Set {myConnectedFlag = value; }} Send Public Bull {get {mySendingFlag return}; } Set {mySendingFlag = value; }} Public Bull Checker Updates {get myUpdateFlag;} {myUpdateFlag = value; set on; }} Public string client configuration {get {myclientConfiguration; } Set {myClientConfiguration = value; }}}

While the service is only running, the memory usage in the Task Manager remains stable, even if the service is always updating the object with the status information when the client starts, Both memms begin to increase, and never go down.

This is the problem that I have told about finding memory leaks.

It appears that on different machines, some do not show any memory increases, but these machines reliably reproduce this problem. Running .NET Memory Profiler shows that on the service, there is an increasing number of "new instances", with only one or two "deleted" names in tab type / resources, where the namespace / system kernel and name / resource HeapMemory I'm still trying to learn how to use Memory Profiler, so I apologize that this is a wrong information, and where I should look and I would appreciate it.

Once this object, with just a few parameters to read and write, there is no file, which I can see does not have any allocation of memory, and even then my memory usage is only at that time It seems to go up when I start a connection to that object from the client and read it. Any other and all input will be appreciated, because I want to avoid dragging this code and want to change it to designated pipes or similar, but I am reaching that point as soon as my only option.

, where your service extends the object,

 < Code> serviceConfigRemote = new service configuredDataDemote ();  

looks like

  Service ConfigurationMote = ServiceConnected Data Remote. Instance;  

Instead?

At the very least, the way you have it, you are making two separate examples on the server side, used by a stable example property Going to Starters and another configuration via remote service (remote) clear construction. It can also serve well to add a personal constructor to that class so that nothing in addition to the static initializer, do not instantiate the singleton.

It can never be resolved to a growing memory, but it certainly seems something to know about a problem.

Edit:

Here are some more suggestions that 'get tooth on the net:

  • Add [MTAThread] host service.
  • Remote services. Disconnect (this.serviceConfigRemote); When you are shutting down the host service.

Hope it can help.


Comments

Popular posts from this blog

c# - How to capture HTTP packet with SharpPcap -

jquery - SimpleModal Confirm fails to submit form -

php - Multiple Select with Explode: only returns the word "Array" -