[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Chicken-users] heap size or macro problem
From: |
Rick Taube |
Subject: |
Re: [Chicken-users] heap size or macro problem |
Date: |
Mon, 5 Nov 2007 06:30:04 -0600 |
The first thing to check is whether you perform any Scheme->C calls
with callbacks into Scheme: if these are not properly declared as
"safe",
since this always (sooner or later) leads to trouble.
wow thanks so much you have saved us days of work with this tip! this
is exactly what we are doing. a user scheme function gets added to a
JUCE scheduling/scheme thread, which then does a callback on the
fuctino at the correct time. during that callback the user's (scheme)
function will certainly call into C again, for example sending midi
notes to the output port. originally we were calling the user's
function (the 'closure' var) from the scheme thread using C_callback
like this:
{
double nexttime ;
C_word *elapsed_ptr;
C_word elapsed_word;
C_word closure;
closure = CHICKEN_gc_root_ref(gcroot);
elapsed_ptr = C_alloc(1);
elapsed_word = C_flonum( &elapsed_ptr, time - start);
C_save( elapsed_word );
nexttime = C_c_double( C_callback(closure, 1));
}
i *think* this code was working but the downside is that every user
funcino has to be wrapped with error handling code to avoid crashes
under the callback... so we replaced that first version with one that
uses a define-external
(define-external (run_process (scheme-object closure) (double
elapsed)) double
( closure elapsed))
that get called like this:
nexttime = run_process( CHICKEN_gc_root_ref(closureGCRoot),
time - start);
which -- if it worked -- i think would be a better solution becuse
the we can put the error handling code in the external point instead
of inside every user function, eg:
(define-external ...)
(with-no-errors ( closure elapsed))
if these are not properly declared as "safe",
since this always (sooner or later) leads to trouble.
so clearly we are not doing this right because nothing is declared as
safe however I dont see in the docs how to declare the run_process as
safe, can you help me out? or should we just use the first version
and wrap each clouser with error proctection boilerplate?
thanks!
--rick