Manually pushing 43k+ elements to an array

classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Manually pushing 43k+ elements to an array

tommedema
Hi, I have about 71k elements I manually push to an array (I had a script write the code for me).

When I compile it, the compiler fails without an error message. When I try to push about 42k elements or less, it does work. At 43k+ it does not work.

Why is this? How would I solve this "limitation"?

Regards,
Tom

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Manually pushing 43k+ elements to an array

singmajesty
Each data type has a built-in limit to its maximum size. Perhaps that is  
what is going on here?

You might consider working around this by replacing the array with a  
function. Instead of accessing myArray[100] directly, you can call a  
function, myArray (100), which then returns the value. In this way, you  
could split your data into multiple arrays, so the actual data is held in  
multiple arrays, but throughout your code you only need to reference one  
method. The method could have simple logic built in, to serve it from the  
first array if the index is smaller than 42,000, or from the second array  
if it is larger than that.



On Fri, 16 Jul 2010 15:29:15 -0700, Tom <[hidden email]> wrote:

> Hi, I have about 71k elements I manually push to an array (I had a script
> write the code for me).
>
> When I compile it, the compiler fails without an error message. When I  
> try
> to push about 42k elements or less, it does work. At 43k+ it does not  
> work.
>
> Why is this? How would I solve this "limitation"?
>
> Regards,
> Tom


--
Joshua Granick
Owner / Lead Developer
[ eclecticdesignstudio ]
P: (916) 889-7306

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Manually pushing 43k+ elements to an array

tommedema
Reading 71k rows from a file and then add them to the array one by one works fine, so that should not be the problem.

I think it's a problem with the compiler haxe.exe, not being able to compile such a big source file or something.

- Tom

2010/7/17 Joshua Granick <[hidden email]>
Each data type has a built-in limit to its maximum size. Perhaps that is what is going on here?

You might consider working around this by replacing the array with a function. Instead of accessing myArray[100] directly, you can call a function, myArray (100), which then returns the value. In this way, you could split your data into multiple arrays, so the actual data is held in multiple arrays, but throughout your code you only need to reference one method. The method could have simple logic built in, to serve it from the first array if the index is smaller than 42,000, or from the second array if it is larger than that.




On Fri, 16 Jul 2010 15:29:15 -0700, Tom <[hidden email]> wrote:

Hi, I have about 71k elements I manually push to an array (I had a script
write the code for me).

When I compile it, the compiler fails without an error message. When I try
to push about 42k elements or less, it does work. At 43k+ it does not work.

Why is this? How would I solve this "limitation"?

Regards,
Tom


--
Joshua Granick
Owner / Lead Developer
[ eclecticdesignstudio ]
P: (916) 889-7306

--
haXe - an open source web programming language
http://haxe.org


--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Manually pushing 43k+ elements to an array

Nicolas Cannasse
In reply to this post by tommedema
Tom a écrit :
> Hi, I have about 71k elements I manually push to an array (I had a
> script write the code for me).
>
> When I compile it, the compiler fails without an error message. When I
> try to push about 42k elements or less, it does work. At 43k+ it does
> not work.
>
> Why is this? How would I solve this "limitation"?

You are most likely triggering a stack overflow in the haXe parser,
please submit a report on http://code.google.com/p/haxe/issues with a
source file that reproduce the issue.

Best,
Nicolas

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Manually pushing 43k+ elements to an array

Hudson Ansley
In reply to this post by tommedema
I know you are not asking for ways to avoid doing all those pushes,
but since I have done something similar, thought I'd throw out this
suggestion anyway... Since you have a script write the code, could you
have it just write out an array assignment directly? Not sure if this
would also run into compile errors for a line that large, but I think
it would be much more efficient than the pushes, both code size and
CPU...

What I have done in the past is convert XML into a single object
assignment with xslt - the xml was about 300k and the resulting
assignment compiled in a swf (actually, this was AS code, not haxe,
but should work the same way.... ) was about 21k, with no XML parsing
needed :-)

Regards,
Hudson

--
haXe - an open source web programming language
http://haxe.org