git.iko.soy/typeable/postgresql-simple
on master help sign in
Tweak warning regarding leaking libpq Results
commitec0c3a6ad8149d99fa16c7b36e13808d8d553724 authorLeon P Smith <leon@melding-monads.com> dateFri 4 May 2012, 17:22 (14 years ago) parent113cef2
1 file changed+8−6
src/Database/PostgreSQL/Simple/FromField.hs+8−6
src/Database/PostgreSQL/Simple/FromField.hs+8−6
@@ -107,12 +107,14 @@ class FromField a where
107107 -- library instances, this will usually be a single 'ResultError', but
108108 -- may be a 'UnicodeException'.
109109 --
110− -- Implementations of the 'fromField' method should not retain any
111− -- references to the ByteString it is passed, as this will cause the
112− -- entire @LibPQ.'PQ.Result'@ to be retained. For example, the
113− -- instance for 'ByteString' uses 'B.copy' to avoid this issue. Note that
114− -- using bytestring functions such as 'B.drop' and 'B.takeWhile' alone
115− -- will also trigger this memory leak.
110+ -- Implementations of 'fromField' should not retain any references to
111+ -- the 'Field' nor the 'ByteString' arguments after the result has
112+ -- been evaluated to WHNF. Such a reference causes the entire
113+ -- @LibPQ.'PQ.Result'@ to be retained.
114+ --
115+ -- For example, the instance for 'ByteString' uses 'B.copy' to avoid
116+ -- such a reference, and that using bytestring functions such as 'B.drop'
117+ -- and 'B.takeWhile' alone will also trigger this memory leak.
116118
117119instance (FromField a) => FromField (Maybe a) where
118120 fromField _ Nothing = pure Nothing