Hello, perl-xs. I have a problem with memory reallocation when using a Perl interpreter embeded in my application. (I use few interpreters in few threads. For each interpreter exists its own thread.)
It seems that if we create more than one interpreter we must delete them all at one place. Flat example: 0: 1: int main(int argc, char **argv) 2: { 3: PerlInterpreter *one_perl, *two_perl; 4: char *one_args[] = { "one_perl", "-e", "print qq(Hi, I'm $^X\n)" }; 5: char *two_args[] = { "two_perl", "-e", "print qq(Hi, I'm $^X\n)" }; 6: 7: PERL_SYS_INIT3(&argc,&argv,&env); 8: one_perl = perl_alloc(); 9: 10: PERL_SET_CONTEXT(one_perl); 11: perl_construct(one_perl); 12: 13: PERL_SET_CONTEXT(one_perl); 14: perl_parse(one_perl, NULL, 3, one_args, (char **)NULL); 15: 16: PERL_SET_CONTEXT(one_perl); 17: perl_run(one_perl); 18: 19: PERL_SET_CONTEXT(one_perl); 20: perl_destruct(one_perl); 21: 22: PERL_SET_CONTEXT(one_perl); 23: perl_free(one_perl); 24: 25: two_perl = perl_alloc(); 26: PERL_SET_CONTEXT(two_perl); 27: perl_construct(two_perl); 28: PERL_SET_CONTEXT(two_perl); 29: perl_parse(two_perl, NULL, 3, two_args, (char **)NULL); 30: PERL_SET_CONTEXT(two_perl); 31: perl_run(two_perl); 32: //PERL_SET_CONTEXT(one_perl); 33: //perl_free(one_perl); 34: PERL_SET_CONTEXT(two_perl); 35: perl_destruct(two_perl); 36: PERL_SET_CONTEXT(two_perl); 37: perl_free(two_perl); 38: 39: PERL_SYS_TERM(); 40: 41: return 0; 42:} Exception is thrown in 29 line. If we comment 22, 23 line and uncomment 32 and 33 lines, then all will be OK. Questions: Please, point me to error in the code or propose method to delete interpreters separately. -- Best Regards, Irene , C++ Developer of ISS Art, Ltd., Omsk, Russia. http://issart.com http://issart.com/index/Portfolio/cpp&lang=eng mailto:[EMAIL PROTECTED]