[cffi-devel] Memory limit when using with-foreign-pointer?

Carlo Hamalainen carlo.hamalainen at gmail.com
Tue Feb 8 05:51:08 UTC 2011


Hi,

I have a small test program that tries to allocate 100Mb and then say hello:

;;;;;;;;;;;;;;;; start of malloc-test.lisp ;;;;;;;;;;;;
(asdf:oos 'asdf:load-op :cffi)
(defpackage :malloc-test (:use :common-lisp :cffi))
(in-package :malloc-test)

; Attempt to malloc 100Mb of memory and say hello
(with-foreign-pointer (data (* 100 1048576 (foreign-type-size :char)))
  (print "hello"))
;;;;;;;;;;;;;;;; end of malloc-test.lisp ;;;;;;;;;;;;;


But when I run it using SBCL on Ubuntu 10.10 32bit, it complains about
some value not being of type (MOD 536870909). Is this a deliberate
limit on the part of CFFI or SBCL? If so where can I adjust this
limit?


$ sbcl
This is SBCL 1.0.40.0.debian, an implementation of ANSI Common Lisp.
More information about SBCL is available at <http://www.sbcl.org/>.

SBCL is free software, provided as is, with absolutely no warranty.
It is mostly in the public domain; some portions are provided under
BSD-style licenses.  See the CREDITS and COPYING files in the
distribution for more information.
* (load "malloc-test.lisp")

; loading system definition from /usr/share/common-lisp/systems/cffi.asd into
; #<PACKAGE "ASDF0">
; registering #<SYSTEM CFFI {ADD22C1}> as CFFI
; loading system definition from /usr/share/common-lisp/systems/babel.asd into
; #<PACKAGE "ASDF0">
; registering #<SYSTEM BABEL {B2CB081}> as BABEL
; loading system definition from /usr/share/common-lisp/systems/alexandria.asd
; into #<PACKAGE "ASDF0">
; registering #<SYSTEM :ALEXANDRIA {B4AF1B1}> as ALEXANDRIA
; loading system definition from
; /usr/share/common-lisp/systems/trivial-features.asd into #<PACKAGE "ASDF0">
; registering #<SYSTEM TRIVIAL-FEATURES {ABBB251}> as TRIVIAL-FEATURES

debugger invoked on a TYPE-ERROR in thread #<THREAD "initial thread" RUNNING
                                             {AACA871}>:
  The value 838860800 is not of type (MOD 536870909).

Type HELP for debugger help, or (SB-EXT:QUIT) to exit from SBCL.

restarts (invokable by number or by possibly-abbreviated name):
  0: [ABORT] Exit debugger, returning to top level.

((LAMBDA ()))
0]






Thanks,


-- 
Carlo Hamalainen
http://carlo-hamalainen.net




More information about the cffi-devel mailing list