471,315 Members | 1,770 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,315 software developers and data experts.

JScript Memory Leak

I have been using the JScript eval() method from C# to evaluate
conditional logic at run-time. I found that implementing a solution
similar to the example posted at:
http://www.odetocode.com/Code/80.aspx, seems to handle memory the most
efficiently. However, if executing in a tight loop (say, while(true){//
jscript eval}, JScript will leak memory and grow the virtual memory
until the performance of the machine has been degraded significantly. I
have noticed however that if I do not evaluate regular expressions the
JScript eval works wonderfully. If I eval a regex though (i.e.
/foo/.test('foobar')), the memory will leak as I described above. I
have searched and searched for any information about this and have not
been able to find anything. Should I be posting this to the JScript
group for this kind of information? Does anyone know why JScript leaks
memory like that (only under certain conditions)?

Thanks,
Mitch

Feb 3 '06 #1
3 1862
Mitch,

Why are you using eval to evaluate the regular expressions? Why not
just use the Regex class in the System.Text.RegularExpressions namespace?

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mitch Freed" <mi*********@gmail.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
I have been using the JScript eval() method from C# to evaluate
conditional logic at run-time. I found that implementing a solution
similar to the example posted at:
http://www.odetocode.com/Code/80.aspx, seems to handle memory the most
efficiently. However, if executing in a tight loop (say, while(true){//
jscript eval}, JScript will leak memory and grow the virtual memory
until the performance of the machine has been degraded significantly. I
have noticed however that if I do not evaluate regular expressions the
JScript eval works wonderfully. If I eval a regex though (i.e.
/foo/.test('foobar')), the memory will leak as I described above. I
have searched and searched for any information about this and have not
been able to find anything. Should I be posting this to the JScript
group for this kind of information? Does anyone know why JScript leaks
memory like that (only under certain conditions)?

Thanks,
Mitch

Feb 3 '06 #2
Thanks for the reply Nicholas. What I'm using the eval for is to build
an statement piece by piece and then I eval it using the eval()
function. So by the time I'm done building the statement it could look
something like:

1 == 1 && /foo/i.text('foobar') && (1 != 2 || 'a' == 'b')

Right know I am trying to eval the expression as a whole, instead of
piece by piece -- makes it easier for me. I have actually been able to
work around the memory issues when using a regex in the eval(), but I
am really interested to know what causes the memory issues. I can give
an example piece of code that reproduces the memory problems if anyone
is interested.

Feb 3 '06 #3
Mitch,

Well, where are you seeing the virtual memory grow? You aren't looking
at this in the task manager are you?

Also, while I see how useful this kind of dynamic evaluation can be, you
really should have more concrete implementations of the code path.

Not that it helps your current situation, but JScript goes through a lot
of hoops in order to provide eval, from what it seems.

--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Mitch Freed" <mi*********@gmail.com> wrote in message
news:11**********************@f14g2000cwb.googlegr oups.com...
Thanks for the reply Nicholas. What I'm using the eval for is to build
an statement piece by piece and then I eval it using the eval()
function. So by the time I'm done building the statement it could look
something like:

1 == 1 && /foo/i.text('foobar') && (1 != 2 || 'a' == 'b')

Right know I am trying to eval the expression as a whole, instead of
piece by piece -- makes it easier for me. I have actually been able to
work around the memory issues when using a regex in the eval(), but I
am really interested to know what causes the memory issues. I can give
an example piece of code that reproduces the memory problems if anyone
is interested.

Feb 3 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

8 posts views Thread by ranjeet.gupta | last post: by
17 posts views Thread by José Joye | last post: by
4 posts views Thread by Don Nell | last post: by
20 posts views Thread by jeevankodali | last post: by
23 posts views Thread by James | last post: by
7 posts views Thread by Salvador | last post: by
3 posts views Thread by Jim Land | last post: by
22 posts views Thread by Peter | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.