473,387 Members | 1,464 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 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 1938
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Mark D. Anderson | last post by:
About a month ago Richard Cornford did an interesting analysis of a memory leak in jscript (internet explorer) when there are "circular" references between DOM objects and (real) jscript objects:...
8
by: ranjeet.gupta | last post by:
Dear All Is the Root Cause of the Memory corruption is the Memory leak, ?? suppose If in the code there is Memory leak, Do this may lead to the Memory Corruption while executing the program ? ...
17
by: José Joye | last post by:
Hi, I have implemented a Service that is responsible for getting messages from a MS MQ located on a remote machine. I'm getting memory leak from time to time (???). In some situation, it is...
4
by: Don Nell | last post by:
Hello Why is there a memory leak when this code is executed. for(;;) { ManagementScope scope = new ManagementScope(); scope.Options.Username="username"; scope.Options.Password="password";...
20
by: jeevankodali | last post by:
Hi I have an .Net application which processes thousands of Xml nodes each day and for each node I am using around 30-40 Regex matches to see if they satisfy some conditions are not. These Regex...
23
by: James | last post by:
The following code will create memory leaks!!! using System; using System.Diagnostics; using System.Data; using System.Data.SqlClient; namespace MemoryLeak
7
by: Salvador | last post by:
Hi, I am using WMI to gather information about different computers (using win2K and win 2K3), checking common classes and also WMI load balance. My application runs every 1 minute and reports...
3
by: Jim Land | last post by:
Jack Slocum claims here http://www.jackslocum.com/yui/2006/10/02/3-easy-steps-to-avoid-javascript- memory-leaks/ that "almost every site you visit that uses JavaScript is leaking memory". ...
22
by: Peter | last post by:
I am using VS2008. I have a Windows Service application which creates Crystal Reports. This is a multi theaded application which can run several reports at one time. My problem - there is a...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.