File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -247,6 +247,10 @@ class ARROW_EXPORT ProxyMemoryPool : public MemoryPool {
247247};
248248
249249// / EXPERIMENTAL MemoryPool wrapper with an upper limit
250+ // /
251+ // / Checking for limits is not done in a fully thread-safe way, therefore
252+ // / multi-threaded allocations might be able to go successfully above the
253+ // / configured limit.
250254class ARROW_EXPORT CappedMemoryPool : public MemoryPool {
251255 public:
252256 CappedMemoryPool (MemoryPool* wrapped_pool, int64_t bytes_allocated_limit)
@@ -256,6 +260,11 @@ class ARROW_EXPORT CappedMemoryPool : public MemoryPool {
256260 using MemoryPool::Reallocate;
257261
258262 Status Allocate (int64_t size, int64_t alignment, uint8_t ** out) override {
263+ // XXX Another thread may allocate memory between the limit check and
264+ // the `Allocate` call. It is possible for the two allocations to be successful
265+ // while going above the limit.
266+ // Solving this issue would require refactoring the `MemoryPool` implementation
267+ // to delegate the limit check to `MemoryPoolStats`.
259268 const auto attempted = size + wrapped_->bytes_allocated ();
260269 if (ARROW_PREDICT_FALSE (attempted > bytes_allocated_limit_)) {
261270 return OutOfMemory (attempted);
You can’t perform that action at this time.
0 commit comments