tomw1975 has asked for the wisdom of the Perl Monks concerning the following question:
#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; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Memory leak issue with Embedded Perl
by dash2 (Hermit) on Jul 24, 2003 at 23:30 UTC | |
by tomw1975 (Sexton) on Jul 24, 2003 at 23:36 UTC | |
by belg4mit (Prior) on Jul 25, 2003 at 01:11 UTC | |
by tomw1975 (Sexton) on Jul 25, 2003 at 15:53 UTC | |
|
Re: Memory leak issue with Embedded Perl
by tomw1975 (Sexton) on Jul 25, 2003 at 17:02 UTC | |
by Anonymous Monk on Jul 26, 2003 at 09:19 UTC | |
by tomw1975 (Sexton) on Jul 27, 2003 at 20:23 UTC |