I also get this error. It’s intermittent for me too.
I’m using the NCrunch runner and it seems the test host is x86/32bit.
Here is a partially redacted stack trace:
System.AggregateException: One or more errors occurred.
System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
at System.Runtime.InteropServices.Marshal.AllocHGlobal(IntPtr cb)
at EventStore.Core.TransactionLog.Chunks.TFChunk.TFChunk.CreateInMemChunk(ChunkHeader chunkHeader, Int32 fileSize)
at EventStore.Core.TransactionLog.Chunks.TFChunk.TFChunk.InitNew(ChunkHeader chunkHeader, Int32 fileSize)
at EventStore.Core.TransactionLog.Chunks.TFChunk.TFChunk.CreateWithHeader(String filename, ChunkHeader header, Int32 fileSize, Boolean inMem)
at EventStore.Core.TransactionLog.Chunks.TFChunk.TFChunk.CreateNew(String filename, Int32 chunkSize, Int32 chunkStartNumber, Int32 chunkEndNumber, Boolean isScavenged, Boolean inMem)
at EventStore.Core.TransactionLog.Chunks.TFChunkManager.AddNewChunk()
at EventStore.Core.TransactionLog.Chunks.TFChunkDb.Open(Boolean verifyHash, Boolean readOnly)
at EventStore.Core.ClusterVNode…ctor(TFChunkDb db, ClusterVNodeSettings vNodeSettings, IGossipSeedSource gossipSeedSource, InfoController infoController, ISubsystem[] subsystems)
at EventStore.ClientAPI.Embedded.EmbeddedVNodeBuilder.Build()
at --.MicroServices.Common.General.TestingHelpers.InMemoryEventStore…ctor() in C:\dev–\microservice-poc\MicroService-Common–.MicroServices.Common.General\TestingHelpers\EmbeddedEventStore.cs:line 19
at --.–.Service.UnitTests.Itineraries.TheItinerariesController.<.ctor>b__3_0(ContainerBuilder builder) in C:\dev–\microservice-poc—Service–.--.Service.UnitTests\Itineraries\ItinerariesControllerTests.cs:line 438
at System.Action`1.Invoke(T obj)
at Autofac.Core.Lifetime.LifetimeScope.CreateScopeRestrictedRegistry(Object tag, Action`1 configurationAction)
at Autofac.Core.Lifetime.LifetimeScope.BeginLifetimeScope(Object tag, Action`1 configurationAction)
at Autofac.Core.Lifetime.LifetimeScope.BeginLifetimeScope(Action`1 configurationAction)
at Autofac.Core.Container.BeginLifetimeScope(Action`1 configurationAction)
at ControllerTests.ApiControllerTestBase`1.<>c__DisplayClass2.b__1()
at System.Lazy`1.CreateValue()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Lazy`1.get_Value()
at ControllerTests.ApiControllerTestBase`1.Dispose(Boolean disposing)
at ControllerTests.ApiControllerTestBase`1.Dispose()
at Xunit.Sdk.ExecutionTimer.Aggregate(Action action)
at ReflectionAbstractionExtensions.DisposeTestClass(ITest test, Object testClass, IMessageBus messageBus, ExecutionTimer timer, CancellationTokenSource cancellationTokenSource)
at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass45_0.b__1()
at Xunit.Sdk.ExceptionAggregator.Run(Action code)
System.OutOfMemoryException: Insufficient memory to continue the execution of the program.
at System.Runtime.InteropServices.Marshal.AllocHGlobal(IntPtr cb)
at EventStore.Core.TransactionLog.Chunks.TFChunk.TFChunk.CreateInMemChunk(ChunkHeader chunkHeader, Int32 fileSize)
at EventStore.Core.TransactionLog.Chunks.TFChunk.TFChunk.InitNew(ChunkHeader chunkHeader, Int32 fileSize)
at EventStore.Core.TransactionLog.Chunks.TFChunk.TFChunk.CreateWithHeader(String filename, ChunkHeader header, Int32 fileSize, Boolean inMem)
at EventStore.Core.TransactionLog.Chunks.TFChunk.TFChunk.CreateNew(String filename, Int32 chunkSize, Int32 chunkStartNumber, Int32 chunkEndNumber, Boolean isScavenged, Boolean inMem)
at EventStore.Core.TransactionLog.Chunks.TFChunkManager.AddNewChunk()
at EventStore.Core.TransactionLog.Chunks.TFChunkDb.Open(Boolean verifyHash, Boolean readOnly)
at EventStore.Core.ClusterVNode…ctor(TFChunkDb db, ClusterVNodeSettings vNodeSettings, IGossipSeedSource gossipSeedSource, InfoController infoController, ISubsystem[] subsystems)
at EventStore.ClientAPI.Embedded.EmbeddedVNodeBuilder.Build()
at --.MicroServices.Common.General.TestingHelpers.InMemoryEventStore…ctor() in C:\dev–\microservice-poc\MicroService-Common–.MicroServices.Common.General\TestingHelpers\EmbeddedEventStore.cs:line 19
at --.–.Service.UnitTests.Itineraries.TheItinerariesController.<.ctor>b__3_0(ContainerBuilder builder) in C:\dev–\microservice-poc—Service–.--.Service.UnitTests\Itineraries\ItinerariesControllerTests.cs:line 438
at System.Action`1.Invoke(T obj)
at Autofac.Core.Lifetime.LifetimeScope.CreateScopeRestrictedRegistry(Object tag, Action`1 configurationAction)
at Autofac.Core.Lifetime.LifetimeScope.BeginLifetimeScope(Object tag, Action`1 configurationAction)
at Autofac.Core.Lifetime.LifetimeScope.BeginLifetimeScope(Action`1 configurationAction)
at Autofac.Core.Container.BeginLifetimeScope(Action`1 configurationAction)
at ControllerTests.ApiControllerTestBase`1.<>c__DisplayClass2.b__1()
at System.Lazy`1.CreateValue()
— End of stack trace from previous location where exception was thrown —
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Lazy`1.get_Value()
at ControllerTests.ApiControllerTestBase`1.Dispose(Boolean disposing)
at ControllerTests.ApiControllerTestBase`1.Dispose()
at Xunit.Sdk.ExecutionTimer.Aggregate(Action action)
at ReflectionAbstractionExtensions.DisposeTestClass(ITest test, Object testClass, IMessageBus messageBus, ExecutionTimer timer, CancellationTokenSource cancellationTokenSource)
at Xunit.Sdk.TestInvoker`1.<>c__DisplayClass45_0.b__1()
at Xunit.Sdk.ExceptionAggregator.Run(Action code)
And in case you’re wondering what EmbeddedEventStore.cs is, here you go: Line 19 is “node = EmbeddedVNodeBuilder.”
public class InMemoryEventStore : IDisposable
{
// thanks https://github.com/yreynhout/AggregateSource/blob/master/src/EventStore/AggregateSource.EventStore.IntegratedTests/Framework/EmbeddedEventStore.cs
private bool disposed;
private readonly ClusterVNode node;
public InMemoryEventStore()
{
node = EmbeddedVNodeBuilder.
AsSingleNode().
OnDefaultEndpoints().
RunInMemory().
Build();
node.Start();
var tcs = new TaskCompletionSource<object>();
node.NodeStatusChanged += (sender, args) =>
{
if (args.NewVNodeState == VNodeState.Master)
tcs.SetResult(null);
};
tcs.Task.Wait();
var connection = EmbeddedEventStoreConnection.Create(node);
connection.ConnectAsync().Wait();
Connection = connection;
}
public IEventStoreConnection Connection { get; private set; }
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
~InMemoryEventStore()
{
Dispose(false);
}
protected virtual void Dispose(bool disposing)
{
if (disposed)
return;
if (disposing)
{
// free other managed objects that implement
// IDisposable only
Connection?.Close();
Connection?.Dispose();
node?.Stop();
}
// release any unmanaged objects
// set the object references to null
disposed = true;
}
}
Anyone got any idea why this might be happening? memory leak perhaps?