/// <summary> /// Create JVM. /// </summary> /// <param name="cfg">Configuration.</param> /// <param name="cbs">Callbacks.</param> /// <returns>Context.</returns> internal static void CreateJvmContext(IgniteConfiguration cfg, UnmanagedCallbacks cbs) { lock (SyncRoot) { // 1. Warn about possible configuration inconsistency. JvmConfiguration jvmCfg = JvmConfig(cfg); if (!cfg.SuppressWarnings && _jvmCfg != null) { if (!_jvmCfg.Equals(jvmCfg)) { Console.WriteLine("Attempting to start Ignite node with different Java " + "configuration; current Java configuration will be ignored (consider " + "starting node in separate process) [oldConfig=" + _jvmCfg + ", newConfig=" + jvmCfg + ']'); } } // 2. Create unmanaged pointer. void *ctx = CreateJvm(cfg, cbs); cbs.SetContext(ctx); // 3. If this is the first JVM created, preserve it. if (_ctx == null) { _ctx = ctx; _jvmCfg = jvmCfg; _mem = new PlatformMemoryManager(1024); } } }
public void TestPooledStreamReallocate() { var mem = new PlatformMemoryManager(256).Allocate(); Assert.IsTrue(mem is PlatformPooledMemory); CheckStreamReallocate(mem); }
public void TestUnpooledStreamReallocate() { PlatformMemoryManager mgr = new PlatformMemoryManager(256); for (int i = 0; i < 3; i++) { mgr.Allocate(); } var mem = mgr.Allocate(); Assert.IsTrue(mem is PlatformUnpooledMemory); CheckStreamReallocate(mem); }
public void TestPooledStreamReallocate() { IPlatformMemory mem = new PlatformMemoryManager(256).Allocate(); try { Assert.IsTrue(mem is PlatformPooledMemory); CheckStreamReallocate(mem); } finally { mem.Release(); } }
public void TestUnpooledStreamReallocate() { PlatformMemoryManager mgr = new PlatformMemoryManager(256); for (int i = 0; i < 3; i++) { mgr.Allocate(); } IPlatformMemory mem = mgr.Allocate(); try { Assert.IsTrue(mem is PlatformUnpooledMemory); CheckStreamReallocate(mem); } finally { mem.Release(); } }
public void TestUnpooled() { PlatformMemoryManager mgr = new PlatformMemoryManager(256); for (int i = 0; i < 3; i++) { mgr.Allocate(); } IPlatformMemory mem1 = mgr.Allocate(); Assert.IsTrue(mem1 is PlatformUnpooledMemory); Assert.IsTrue(mem1.Capacity >= 256); Assert.IsTrue(mem1.Pointer > 0); Assert.IsTrue(mem1.Data > 0); Assert.AreEqual(0, mem1.Length); mem1.Reallocate(512); Assert.IsTrue(mem1.Capacity >= 512); Assert.IsTrue(mem1.Pointer > 0); Assert.IsTrue(mem1.Data > 0); Assert.AreEqual(0, mem1.Length); mem1.Length = 128; Assert.AreEqual(128, mem1.Length); mem1.Release(); IPlatformMemory mem2 = mgr.Allocate(); Assert.AreNotSame(mem1, mem2); Assert.IsTrue(mem2.Capacity >= 256); Assert.IsTrue(mem2.Pointer > 0); Assert.IsTrue(mem2.Data > 0); Assert.AreEqual(0, mem2.Length); mem2.Release(); }
public void TestPooled() { PlatformMemoryManager mgr = new PlatformMemoryManager(256); var mem1 = mgr.Allocate(); Assert.IsTrue(mem1 is PlatformPooledMemory); Assert.IsTrue(mem1.Capacity >= 256); Assert.IsTrue(mem1.Pointer > 0); Assert.IsTrue(mem1.Data > 0); Assert.AreEqual(0, mem1.Length); mem1.Reallocate(512); Assert.IsTrue(mem1.Capacity >= 512); Assert.IsTrue(mem1.Pointer > 0); Assert.IsTrue(mem1.Data > 0); Assert.AreEqual(0, mem1.Length); mem1.Length = 128; Assert.AreEqual(128, mem1.Length); mem1.Release(); Assert.AreSame(mem1, mgr.Allocate()); Assert.IsTrue(mem1.Capacity >= 512); Assert.IsTrue(mem1.Pointer > 0); Assert.IsTrue(mem1.Data > 0); Assert.AreEqual(128, mem1.Length); IPlatformMemory mem2 = mgr.Allocate(); Assert.IsTrue(mem2 is PlatformPooledMemory); IPlatformMemory mem3 = mgr.Allocate(); Assert.IsTrue(mem3 is PlatformPooledMemory); mem1.Release(); Assert.AreSame(mem1, mgr.Allocate()); mem2.Release(); Assert.AreSame(mem2, mgr.Allocate()); mem3.Release(); Assert.AreSame(mem3, mgr.Allocate()); mem1.Release(); mem2.Release(); Assert.AreSame(mem1, mgr.Allocate()); Assert.AreSame(mem2, mgr.Allocate()); IPlatformMemory unpooled = mgr.Allocate(); try { Assert.IsTrue(unpooled is PlatformUnpooledMemory); } finally { unpooled.Release(); } }