{"record":{"id":"60b1ca82477badba","repo":"dotnet/machinelearning","slug":"current-buffer-is-full","errorCode":null,"errorMessage":"Current buffer is full","messagePattern":"Current buffer is full","errorType":"exception","errorClass":"ArgumentException","httpStatus":null,"severity":"error","filePath":"src/Microsoft.Data.Analysis/DataFrameBuffer.cs","lineNumber":77,"sourceCode":"        {\n            EnsureCapacity(1);\n\n            RawSpan[Length] = value;\n            Length++;\n        }\n\n        public void IncreaseSize(int numberOfValues)\n        {\n            EnsureCapacity(numberOfValues);\n            Length += numberOfValues;\n        }\n\n        public void EnsureCapacity(int numberOfValues)\n        {\n            long newLength = Length + (long)numberOfValues;\n            if (newLength > MaxCapacity)\n            {\n                throw new ArgumentException(\"Current buffer is full\", nameof(numberOfValues));\n            }\n\n            if (newLength > Capacity)\n            {\n                //Double buffer size, but not higher than MaxByteCapacity\n                var doubledSize = (int)Math.Min((long)ReadOnlyBuffer.Length * 2, ArrayUtility.ArrayMaxSize);\n                var newCapacity = Math.Max(newLength * Size, doubledSize);\n\n                var memory = new Memory<byte>(new byte[newCapacity]);\n                _memory.CopyTo(memory);\n                _memory = memory;\n            }\n        }\n\n        internal override T this[int index]\n        {\n            set\n            {","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/dotnet/machinelearning/blob/7b76e69cf964daeca3f1377af6bc5543284d56c6/src/Microsoft.Data.Analysis/DataFrameBuffer.cs#L59-L95","documentation":"EnsureCapacity throws when appending numberOfValues more items would push Length past MaxCapacity. The buffer is full and cannot grow further, so the append is rejected with an ArgumentException naming numberOfValues.","triggerScenarios":"Calling Append or IncreaseSize (via EnsureCapacity, src/Microsoft.Data.Analysis/DataFrameBuffer.cs:77) when Length + numberOfValues > MaxCapacity; long-running streaming appends that never cap total size.","commonSituations":"Ingesting very large files into a single column buffer; aggregation loops that accumulate unbounded rows; underestimating dataset size versus the buffer max.","solutions":["Stop appending once Length approaches MaxCapacity and flush/paginate the data","Split ingestion into multiple buffers or DataFrame chunks","Pre-check Length + numberOfValues <= MaxCapacity before appending"],"exampleFix":"// before\nforeach (var row in hugeSource) column.Append(row.Value);\n// after\nforeach (var row in hugeSource) {\n    if (column.Length + 1 > DataFrameBuffer<int>.MaxCapacity) FlushAndReset();\n    column.Append(row.Value);\n}","handlingStrategy":"validation","validationCode":"if (buffer.Length + numberOfValues > DataFrameBuffer<T>.MaxCapacity) FlushAndReset();","typeGuard":null,"tryCatchPattern":"try { buffer.Append(item); }\ncatch (ArgumentException ex) when (ex.Message.Contains(\"Current buffer is full\")) { /* flush, allocate new buffer, retry item */ }","preventionTips":["Track total appended count and paginate before hitting MaxCapacity","Stream large inputs into chunked buffers instead of one giant buffer","Add capacity assertions in ingestion loops"],"tags":["dotnet","buffer","capacity","out-of-memory"],"backgroundTag":"buffer-capacity-exceeded","analyzedSha":"7b76e69cf964daeca3f1377af6bc5543284d56c6","analyzedAt":"2026-09-11T12:35:38.930Z","contentChangedAt":"2026-09-11T12:35:38.930Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}