Fix space leak caused by updateMeasure #8

merged 4 commits into from Mar 11, 2012

2 participants


updateMeasure calls modifyIORef, which does not force the value. Since the Measurement is almost never examined by the program, this results in a memory leak.

In a test program I wrote, a server sending thousands of packets to a client leaks memory pretty quickly (~150 bytes per send, on my 64-bit system). After applying the space leak fix in this pull request, the program successfully sent 1000000 messages to itself using just under 10MB.

This pull request also includes a couple other improvements:

  • Use modifyMVar in the usingState function. This is more concise as well as exception-safe.
  • Minor documentation fixes.
joeyadams added some commits Mar 10, 2012
@joeyadams joeyadams Fix space leak caused by updateMeasure
modifyIORef does not force the value, so if the Measurement object is updated a
bunch of times but never examined, the program will leak memory.
@joeyadams joeyadams Use modifyMVar in usingState for exception safety
Also, force the state value, to avoid potential space leaks.
@joeyadams joeyadams Add links to the 'BufferMode' type in 'client' and 'server' cbfe10e
@joeyadams joeyadams Fix spelling of negotiate/negotiation in documentation 3d0071d
@vincenthz vincenthz merged commit 3d0071d into vincenthz:master Mar 11, 2012

thanks, nice catch for the leak and nice improvements

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment