MCPcopy Create free account
hub / github.com/apache/arrow-rs / test_bytes_drop_releases_pool

Function test_bytes_drop_releases_pool

arrow-buffer/src/bytes.rs:304–330  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

302
303 #[test]
304 fn test_bytes_drop_releases_pool() {
305 let pool = TrackingMemoryPool::default();
306
307 {
308 // Create a buffer with pool
309 let _buffer = unsafe {
310 let layout =
311 std::alloc::Layout::from_size_align(1024, crate::alloc::ALIGNMENT).unwrap();
312 let ptr = std::alloc::alloc(layout);
313 assert!(!ptr.is_null());
314
315 let bytes = Bytes::new(
316 NonNull::new(ptr).unwrap(),
317 1024,
318 Deallocation::Standard(layout),
319 );
320
321 bytes.claim(&pool);
322 bytes
323 };
324
325 assert_eq!(pool.used(), 1024);
326 }
327
328 // Buffer has been dropped, memory should be released
329 assert_eq!(pool.used(), 0);
330 }
331 }
332}

Callers

nothing calls this directly

Calls 2

defaultFunction · 0.85
claimMethod · 0.45

Tested by

no test coverage detected