unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Amirouche Boubekki <amirouche@hypermove.net>
To: Andy Wingo <wingo@pobox.com>
Cc: 24357@debbugs.gnu.org
Subject: bug#24357: pure guile program leaks memory
Date: Sat, 03 Sep 2016 20:49:41 +0200	[thread overview]
Message-ID: <720a442d3c0733ce6ddcb8f0e80a921a@hypermove.net> (raw)
In-Reply-To: <87d1kli9zh.fsf@pobox.com>

[-- Attachment #1: Type: text/plain, Size: 1090 bytes --]

On 2016-09-03 11:54, Andy Wingo wrote:
> On Sat 03 Sep 2016 09:20, Amirouche Boubekki <amirouche@hypermove.net> 
> writes:
> 
>> Using guile 2.1.3, I have a program that:
>> 
>> - reads urls from a text file
>> - download the urls using curl command via popen
>> - output the result to stdout
>> 
>> Also, it relies on n-for-each-par-map for ice-9 threads.
> 
> Can you reduce it please?  For example, remove the use of threads.
> 

Ok. I removed threads and only download the same url over and over 
again.

Here is the error I get on stdout:

    (23) Failed writing body

The program is:

(use-modules (ice-9 popen))


;;; wrapping curl command

(define (curl url)
   (let* ((port (open-input-pipe (format #f "curl -is \"~a\"" url)))
          (response (read-string port)))
     (close-pipe port)
     response))


(define (maybe-curl url)
   (catch #t
     (lambda ()
       (display "." (current-error-port))
       (write (cons url (curl url))))
     (lambda _ '())))

(define urls (map (lambda _ "http://hyperdev.fr/") (iota 1000)))

(display "started")

(for-each maybe-curl urls)

[-- Attachment #2: guile-bug-24357.scm --]
[-- Type: text/plain, Size: 489 bytes --]

(use-modules (ice-9 popen))


;;; wrapping curl command

(define (curl url)
  (let* ((port (open-input-pipe (format #f "curl -is \"~a\"" url)))
         (response (read-string port)))
    (close-pipe port)
    response))


(define (maybe-curl url)
  (catch #t
    (lambda ()
      (display "." (current-error-port))
      (write (cons url (curl url))))
    (lambda _ '())))

(define urls (map (lambda _ "http://hyperdev.fr/") (iota 1000)))

(display "started")

(for-each maybe-curl urls)

  reply	other threads:[~2016-09-03 18:49 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-09-03  7:20 bug#24357: pure guile program leaks memory Amirouche Boubekki
2016-09-03  9:54 ` Andy Wingo
2016-09-03 18:49   ` Amirouche Boubekki [this message]
2016-09-12 17:47     ` Amirouche Boubekki
2017-03-01  9:06       ` Andy Wingo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=720a442d3c0733ce6ddcb8f0e80a921a@hypermove.net \
    --to=amirouche@hypermove.net \
    --cc=24357@debbugs.gnu.org \
    --cc=wingo@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).