Parrot embedding system - Out of memory!
Radovan Baranec
rado.baranec at centrum.sk
Tue Aug 11 11:36:24 UTC 2009
Hi, I finally finished my "little" packet decoder. Now I am able to
decode ether->ipv4->tcp. So I tried to run a few performance tests on a
10GB pcap dump file but I found big problem. Because it is very big
file, subroutine from loaded bytecode is being called many times. On my
surprise every time it is called it allocates memory. So soon there is
not enough memory and linux just kills my program. I am runnig on centos
5, x86_64, custom kernel 2.6.29lb.06. Runcores or flags are not set.
Here is the code:
C code:
#ifdef DEBUG
for(int i = 0; i < 2; i++) {
#else
while (1) {
#endif
retVal = pcap_next_ex(fp, &pktHeader, &pktData);
// capture file ended
if (retVal == -2) {
break;
}
if (retVal < 0) {
printf("Cannot read packet: %s\n", pcap_geterr(fp));
clean();
//spravna reakcia?
return -1;
}
// Timeout expired
if (retVal == 0) {
continue;
}
Parrot_PMC_set_pointer(interp, packet, (void *)pktData);
/*
* Parrot_call_sub_ret_int
* preplni pamat a odstreli ho to
*/
if (Parrot_call_sub_ret_int(interp, sub, "IPII", packet,
(int)pktHeader->caplen, load_bytecode)) {
//if (Parrot_call_sub(interp, sub, "V")) {
acc_packets++;
}
else {
rej_packets++;
}
load_bytecode = 0;
}
Parrot_call_sub_ret_int(interp, sub, "IPII", packet,
(int)pktHeader->caplen, load_bytecode) - this function allocates memory
every time it is being called. The code of subroutine is unimportant
because I also tried to call empty subroutine with no param and local
variables.
Radovan
More information about the parrot-dev
mailing list