Quantcast
Channel: VMware Communities : Unanswered Discussions - vFabric GemFire [ARCHIVED]
Viewing all articles
Browse latest Browse all 532

memory leak when using region.put

$
0
0

I am seeing a weird behaviour when using the c# gemfire client. I am seeing memory leak on both the key and value when putting them into the region.

After further investigation, i note that the GCHandle created in the SafeM2UMConvert() is not properly released. However amazingly, when i set both the value and key to null (note the commented line), both the key and value are correctly garbage-collected. Wonder if anyone can provide a explanation of this behaviour?

 

** i would think that both key and value will be removed upon gc, which isn't the case either. I tried to call gc.collect after put but it does not help.

 

Here is a bit on the implementation,

function Add()

{

     lock(sync)

     {
          var key = new Key();
          var value = new Value(key);
          Region.Put(key, value);

 

          //key = null;

          //value = null; these 2 lines did the magic
}

 

[Serializable]

public class Key: IEquatable<Key>, IGFSerializable

 

[Serializable]

public class Value : IGFSerializable, IEquatable<Value>

 

Here is a bit of the call stack where the handler is created (i used the .net momory profiler to obtain this),
mscorlib!System.Runtime.InteropServices.GCHandle..ctor( object,GCHandleType )
mscorlib!System.Runtime.InteropServices.GCHandle.Alloc( object )
GemStone.GemFire.Cache!<Module>.gemfire.ManagedCacheableKey.{ctor}( ManagedCacheableKey*,IGFSerializable )
GemStone.GemFire.Cache!<Module>.GemStone.GemFire.Cache.?A0xa28d4856.SafeM2UMConvert<struct GemStone::GemFire::Cache::IGFSerializable,class gemfire::ManagedCacheableKey,class gemfire::Serializable,class GemStone::GemFire::Cache::Serializable>( IGFSerializable )
GemStone.GemFire.Cache!GemStone.GemFire.Cache.Region.Put( ICacheableKey,IGFSerializable,IGFSerializable )
GemStone.GemFire.Cache!GemStone.GemFire.Cache.Region.Put( ICacheableKey,IGFSerializable )
Add()


Viewing all articles
Browse latest Browse all 532

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>