By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
449,245 Members | 1,118 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 449,245 IT Pros & Developers. It's quick & easy.

JScript Memory Leak

P: n/a
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
Share this Question
Share on Google+
3 Replies


P: n/a
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

P: n/a
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

P: n/a
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.