#include <EXTERN.h> #include <perl.h> #include <stdio.h> #include <stdlib.h> static PerlInterpreter *my_perl; int count; int counter; char *queue; char *tempPop; char *temp; int i = 0; EXTERN_C void xs_init _((void)); EXTERN_C void boot_DynaLoader _((CV* cv)); EXTERN_C void xs_init(void) { char *file = __FILE__; dXSUB_SYS; /* DynaLoader is a special case */ newXS("DynaLoader::boot_DynaLoader", boot_DynaLoader, file); } /********************************************************************* +*******/ /* PERL Database interface subroutine, should return an array of queue + names*/ /********************************************************************* +*******/ Perldatabase(char pseudo [6], char *queue) { dSP; ENTER; SAVETMPS; PUSHMARK (SP); XPUSHs (sv_2mortal (newSVpv (pseudo,6))); PUTBACK; perl_call_pv("database", G_ARRAY); SPAGAIN; count = POPi; temp=queue; while (count !=0) { tempPop = POPp; memcpy (temp, tempPop, 10); count--; temp = temp+10; } PUTBACK; FREETMPS; LEAVE; } char* interface(char pseudo[6], char *queue) { char *my_argv[] = { "", "dataquery.pl"}; my_perl = perl_alloc(); perl_construct(my_perl); perl_parse(my_perl, xs_init, 2, my_argv, (char **)NULL); perl_run(my_perl); Perldatabase(pseudo, queue); perl_destruct (my_perl); perl_free(my_perl); return (queue); }
Now I am by no means a Perl expert - this is my first Perl venture, but is there anyway to see what is leaking memory? Anyway to fix it? Anything obvious that you guys see? Any tools out there to help with this sort of thing? Anything????#!/usr/bin/perl use SDBM_File; use POSIX; sub database { my ($pseudo) = @_; %dbm; $db_file = "CTIC.dbm"; tie %dbm, 'SDBM_File', $db_file, O_RDWR, 0; #open read only @list=split ("__",$dbm{"$pseudo"}); $count = 0; foreach $item(@list) { $queue1 = $item; $count++; } untie %dbm; @list2 =(@list,$count); return @list2; }
In reply to Memory leak issue with Embedded Perl by tomw1975
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |