dpwright / HaskellNet-SSL

Helpers to connect to SSL/TLS mail servers with HaskellNet
BSD 3-Clause "New" or "Revised" License
21 stars 30 forks source link

IMAP's `fetch` results with extreme memory usage and computer freezing. #16

Closed yuvallanger closed 8 years ago

yuvallanger commented 8 years ago

Reposting from https://github.com/jtdaugherty/HaskellNet/issues/39:

I have written the following function using the HaskellNet and HaskellNet-SSL libraries. Using the "fetch" function results with memory usage blowing up and extreme swapping. What am I doing wrong? Might it be a bug?

import qualified Data.ByteString.Char8       as SB8
import           Network.HaskellNet.IMAP
import           Network.HaskellNet.IMAP.SSL

main = retrieveCSV

retrieveCSV = do
    con <- connectIMAPSSL imapServer
    login con username password
    select con mailbox
    lastMsg <- last <$> search con [ALLs]
    -- this works:
    _ <- fetchHeader con lastMsg
    -- this works:
    _ <- fetchSize con lastMsg
    -- this blows up in memory usage:
    _ <- fetch con lastMsg
    undefined
    where
    imapServer = "imap.gmail.com"
    username   = "example" -- imagine this username is real
    password   = "example" -- imagine this password is real
    mailbox    = "example" -- imagine this mailbox is real
lemol commented 8 years ago

Following the issue at jtdaugherty/HaskellNet#39.