Skip to content

Commit

Permalink
Fix a memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
nikita-volkov committed Oct 19, 2017
2 parents 6439a88 + 45acfd9 commit fa2535a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 6 deletions.
6 changes: 3 additions & 3 deletions library/Hasql/Core/Batch.hs
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,16 @@ instance Applicative Batch where
Batch (\_ psr -> (pure x, psr))
{-# INLINABLE (<*>) #-}
(<*>) (Batch left) (Batch right) =
Batch (\idt psr -> case left idt psr of
Batch (\(!idt) (!psr) -> case left idt psr of
(leftRequest, leftPsr) -> case right idt leftPsr of
(rightRequest, rightPsr) -> (leftRequest <*> rightRequest, rightPsr))

statement :: A.Statement params result -> params -> Batch result
statement (A.Statement template paramOIDs paramBytesBuilder1 paramBytesBuilder2 interpretResponses1 interpretResponses2 prepared) params =
Batch $ \idt psr ->
Batch $ \(!idt) (!psr) ->
if prepared
then case D.lookupOrRegister template paramOIDs psr of
(newOrOldName, newPsr) ->
(!newOrOldName, !newPsr) ->
let
request =
case newOrOldName of
Expand Down
11 changes: 10 additions & 1 deletion profile-heap
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
#!/bin/bash
set -eo pipefail

function wait_till_exists {
while ! test -f "$1"; do
sleep 0.1
done
}

cabal build profiling
cd dist
build/profiling/profiling +RTS -N -hc -i0.01 -L70 -RTS
rm -f profiling.ps
rm -f profiling.hp
build/profiling/profiling +RTS -N -hr -i0.01 -L70 -RTS
hp2ps -e8in -c profiling.hp
wait_till_exists "profiling.ps"
open profiling.ps
8 changes: 6 additions & 2 deletions profiling/Main.hs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,12 @@ main =
do
connection <- connect
traceEventIO "START Session"
Right !result <- fmap force <$> A.session connection (session 10 200 100)
Right !result <- fmap force <$> A.session connection (session 200 10 100)
Right !result <- fmap force <$> A.session connection (session 50 10 100)
Right !result <- fmap force <$> A.session connection (session 50 10 100)
Right !result <- fmap force <$> A.session connection (session 10 50 100)
Right !result <- fmap force <$> A.session connection (session 50 10 100)
Right !result <- fmap force <$> A.session connection (session 10 50 100)
Right !result <- fmap force <$> A.session connection (session 10 50 100)
traceEventIO "STOP Session"
return ()

Expand Down

0 comments on commit fa2535a

Please sign in to comment.