Re: GC and Coroutines
Juan Wajnerman <[email protected]>
| Newsgroups | gmane.comp.programming.garbage-collection.boehmgc |
|---|---|
| Message-ID | <[email protected]> |
Something I noticed is if I run this loop inside a coroutine:
while(true) {
GC_malloc(10240);
}
after some time it crashes with the message "Too many heap sections: Increase MAXHINCR or MAX_HEAP_SECTS".
But it works just fine without coroutines.
On Jan 28, 2014, at 6:59 PM, Juan Wajnerman <[email protected]> wrote:
> The following code works fine, but if you uncomment the commented line, it crashes:
>
> #include <gc/gc.h>
> #include <pcl.h>
> #include <stdio.h>
>
> void coroutine(void *arg)
> {
> int i;
> for (i = 0; i < 1000; ++i)
> {
> printf("%d\n", i);
> GC_malloc(1024);
> }
> }
>
> #define STACK_SIZE 32 * 1024
> coroutine_t c;
>
> int main(int argc, char const *argv[])
> {
> GC_init();
> // GC_malloc(1024);
>
> c = co_create(coroutine, 0, 0, STACK_SIZE);
> co_call(c);
>
> return 0;
> }
>
>
>
> On Jan 28, 2014, at 6:51 PM, Basile Starynkevitch <[email protected]> wrote:
>
>> On Tue, 2014-01-28 at 18:35 -0300, Juan Wajnerman wrote:
>>> I made the stack and the coroutine variables (might be the same value, right?) as global but it still crashes.
>>> Something I noticed is that when I call co_create() without a stack (it allocates its own stack) it works fine if I didn't call GC_malloc() before.
>>> In other words, it crashes if I call GC_malloc() in the main function.
>>>
>>
>>
>> Show the actual code if possible ... I'm not sure to understand you
>> well..
>>
>> Cheers.
>> --
>> Basile STARYNKEVITCH http://starynkevitch.net/Basile/
>> email: basile<at>starynkevitch<dot>net mobile: +33 6 8501 2359
>> 8, rue de la Faiencerie, 92340 Bourg La Reine, France
>> *** opinions {are only mine, sont seulement les miennes} ***
>>
>>
>