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

max length of eval expression

P: n/a
using eval function i am executing a lengthy string expression...in
fact i am framing some string which contains the commands of creating
elements using dom2...this is very very lengthy string

Is there any limitation for that

eval(exp);
here what is max length(limitation) of exp ?

thanks
Sudhakar

Jan 12 '06 #1
Share this Question
Share on Google+
4 Replies


P: n/a
VK

su***************@gmail.com wrote:
eval(exp);
here what is max length(limitation) of exp ?


the available computer memory

Jan 12 '06 #2

P: n/a
this is we are executing on client side....so we can't fix it....a
typical expression length was about 35000 chars...it may go more than
this

Jan 12 '06 #3

P: n/a
VK

su***************@gmail.com wrote:
this is we are executing on client side....so we can't fix it....a
typical expression length was about 35000 chars...it may go more than
this


Sorry, you did not understand, that was the answer, not a question :-)

- What is the maxlength of exp in eval(exp) ?
- The maxlength is the available computer memory.

More precisely it's limited by the allowed string buffer (because exp
is passed as string). JavaScript is memory management free language so
theoretically any variable can take all available memory resource if
needed. From the other side String is using (the same as array)
indexing mechanics for its methods (like charAt) So I would expect some
problems to start after String.length will pass the magic level
4,294,967,295
But from the other side client browse will most probably send your
script to hell with such demands - and much earlier than that. :-)
35000 chars - I never tried but officially nothing illegal.

Jan 12 '06 #4

P: n/a
On 2006-01-12, VK <sc**********@yahoo.com> wrote:

su***************@gmail.com wrote:
this is we are executing on client side....so we can't fix it....a
typical expression length was about 35000 chars...it may go more than
this
Sorry, you did not understand, that was the answer, not a question :-)

- What is the maxlength of exp in eval(exp) ?
- The maxlength is the available computer memory.


yes, I think so, I've used upto 60000 bytes...
More precisely it's limited by the allowed string buffer (because exp
is passed as string).
yes.
JavaScript is memory management free language so theoretically any variable
can take all available memory resource if needed.
From the other side String is using (the same as array)
indexing mechanics for its methods (like charAt) So I would expect some
problems to start after String.length will pass the magic level
4,294,967,295
But from the other side client browse will most probably send your
script to hell with such demands - and much earlier than that. :-)
35000 chars - I never tried but officially nothing illegal.

2 megs less 1 works here. is that likely to be enough?
(I have not tested longer)

try this: (it makes a really long "1+1+1+1+1+1+1+1" by doubling )

var s='1',x;
for(x=20;x;--x)s=s+'+'+s;
alert("length="+s.length+"\nvalue="+ eval(s));

Bye.
Jasen
Jan 13 '06 #5

This discussion thread is closed

Replies have been disabled for this discussion.