For Programmers: Free Programming Magazines  


Home > Archive > AWK > August 2007 > Memory exhausted: error when match() function is called with two different regexp









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Memory exhausted: error when match() function is called with two different regexp
ram

2007-08-22, 6:57 pm

Hi All,

I have the following small snippet of awk code

function test(regexp)
{
match($0, regexp)
}

{
test(": ");
test("=");
}

When I execute the above small snippet of code with a big file as
input I get the following
error:

awk: /var/tmp/awk_test:4: (FILENAME=- FNR=5776) fatal: Memory
exhausted: /: /

Output of top command shows that the memory of awk process increases
gradually.
( I am executing this command in UNIX).

Any idea what is the problem ? and How to solve this?

When I tried calling the test() function with the same parameter I did
not see this error.
Also, when I commented the match() function I did not see this error.

So, It looks like their is a memory leak in match() function when it
is called with two different
regular expression. I may be wrong also.

Thanks,
Ram

ram

2007-08-23, 3:57 am

On Aug 22, 7:42 pm, J=FCrgen Kahrs <Juergen.KahrsDELETET...@vr-web.de>
wrote:
> Which implementation of the AWK language do you use ?
> Which version ? Which Unix ?


I am seeing this memory leak in GNU Awk 3.0.6 on 6.2-RELEASE FreeBSD.

I do not see this memory leak with the same awk version on
4=2E11-RELEASE-p13 FreeBSD.

Thanks,
Ram

ram

2007-08-23, 3:57 am

On Aug 22, 8:24 pm, Ed Morton <mor...@lsupcaemnt.com> wrote:
>
> You're probably right. I'm curious and it may provide you a workaround:
> if you don't mind trying it, what happens when you do either of these:
>
>


1) and 2) are failing with memory error and remaining steps are
working fine.

This may not be a workaround for me because I want to execute the
match()
inside a function by passing the regular exp.

Thanks,
Ram


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com