Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion docs/guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ example, enabling the `ManagedMemoryResource` tells RMM to use
>>> rmm.mr.set_current_device_resource(rmm.mr.ManagedMemoryResource())
```

> :warning: The default resource must be set for any device **before**
> ⚠️ The default resource must be set for any device **before**
> allocating any device memory on that device. Setting or changing the
> resource after device allocations have been made can lead to unexpected
> behaviour or crashes.
Expand Down Expand Up @@ -157,6 +157,16 @@ Similarly, to use a pool of managed memory:
>>> rmm.mr.set_current_device_resource(pool)
```

> ⚠️ Take care when deleting a memory resource object,
> either explicitly or when its reference count drops to zero.
> All buffers that were allocated on that memory resource should
> be freed *before* the memory resource itself is deleted.
>
> Note that a Python exception that's raised in a scope that allocates
> buffers can keep references to the buffers that will keep them alive.
> Use ``traceback.clear_frames`` to ensure those buffers are freed
> before destroying the memory resource.
Comment on lines +165 to +168
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

From this description alone, I don't think I would be able to understand how to avoid this problem.

If you want to link to an issue or include an example of the bad code inline, that is fine.


Other `MemoryResource`s include:

* `FixedSizeMemoryResource` for allocating fixed blocks of memory
Expand Down