# Number of active MailboxProcessors

**URL:** <https://forums.fsharp.org/t/number-of-active-mailboxprocessors/2339>\
**Category:** General\
**Created:** [September 7, 2022, 9:39pm UTC](https://forums.fsharp.org/t/number-of-active-mailboxprocessors/2339 "2022-09-07T21:39:24Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jonoke](https://avatars.discourse-cdn.com/v4/letter/j/a8b319/32.png) [@jonoke](https://forums.fsharp.org/u/jonoke)\
**Post date:** [September 7, 2022, 9:39pm UTC](https://forums.fsharp.org/t/number-of-active-mailboxprocessors/2339/1 "2022-09-07T21:39:24Z")

</div>

Is there a way to get the number of active MailboxProcessors in a system?  
I have implemented BTree using one MailboxProcessor per page, and want to check if I’m leaking any as the tree shrinks.

Note, I did this as a learning exercise, not with any notion it was a useful thing to implement.

---

<div class="post-metadata">

**Author:** ![realparadyne](https://yyz2.discourse-cdn.com/flex030/user_avatar/forums.fsharp.org/realparadyne/32/169_2.png) [@realparadyne](https://forums.fsharp.org/u/realparadyne)\
**Post date:** [September 13, 2022, 9:51am UTC](https://forums.fsharp.org/t/number-of-active-mailboxprocessors/2339/2 "2022-09-13T09:51:53Z")

</div>

MailboxProcessor is just a little class in the standard library, it isn’t intended to be a major architectural thing with metrics and monitoring across all the mailboxes. You can see the code for it here, it’s quite small.

[fsharp/mailbox.fs at master · fsharp/fsharp (github.com)](https://github.com/fsharp/fsharp/blob/master/src/fsharp/FSharp.Core/mailbox.fs)

I’d suggest just making each of your instances increment and decrement a counter (InterlockedIncrement() or even another MailboxProcessor based agent that you send add/remove messages to!)
