Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Re: Memory exhausted: error when match() function is called with
ram wrote:
> 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
>

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)
function test(foo) { regexp=foo; match($0, regexp) }
{
test(": ")
test("=")
}

2)
function test() { match($0, regexp) }
{
regexp=": "; test()
regexp="=";  test()
}

3)
{
regexp=": "; match($0, regexp)
regexp="=";  match($0, regexp)
}

4)
{
match($0, ": ")
match($0, "=")
}

Regards,

Ed.

Report this thread to moderator Post Follow-up to this message
Old Post
Ed Morton
08-22-07 11:57 PM


Re: Memory exhausted: error when match() function is called with
Ed Morton wrote:

> ram 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)
>     function test(foo) { regexp=foo; match($0, regexp) }
>     {
>         test(": ")
>         test("=")
>     }
>
> 2)
>     function test() { match($0, regexp) }
>     {
>         regexp=": "; test()
>         regexp="=";  test()
>     }
>
> 3)
>     {
>         regexp=": "; match($0, regexp)
>         regexp="=";  match($0, regexp)
>     }
>
> 4)
>     {
>         match($0, ": ")
>         match($0, "=")
>     }
>
> Regards,
>
>     Ed.

Oh, and 1 more:

5)
BEGIN{ regexp1=": "; regexp2="=" }
{
match($0, regexp1)
match($0, regexp2)
}

Regards,

Ed.

Report this thread to moderator Post Follow-up to this message
Old Post
Ed Morton
08-22-07 11:57 PM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

AWK archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 04:07 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.