# Week11 Update ## TL;DR Write tests for the [libp2p pubsub streams management](https://github.com/libp2p/specs/tree/e5af9174d2e07fc2be6ee720d215c1193bb21cc1/pubsub#stream-management) and [pubsub peers membership](https://github.com/libp2p/specs/blob/e5af9174d2e07fc2be6ee720d215c1193bb21cc1/pubsub/gossipsub/gossipsub-v1.0.md#peering-state) in the zig-libp2p, opened the [PR](https://github.com/zen-eth/zig-libp2p/pull/68), fixed a tricky memory free bug. ## Memory Release Order Issue When I was testing the gossipsub peers streams management feature, I found a tricky bug. When I closed outgoing and incoming streams at the same time, suffered a memory free issue. I spent several days debugging this bug. The main problem was the order of resource release. I didn't know that when lsquic library frees the resource, it may also invoke the callback function such `onConnClosed`. However before I call lsquic to free resources, I already freed other resource which used in the `onConnClosed`. After the code refactor, I adjusted the order of the resources release and add a lot of tests to cover most possible cases. ## Next Start to work on gossipsub handle incoming rpc messages in zig-libp2p.