473,320 Members | 1,713 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,320 software developers and data experts.

Array.sort return "out of memory" in IE and Mozilla


let's say you have:

var games = new Array();
games[gameNum] = new GAME(gameNum, rotNum1, rotNum2, ... );

(

so a sparsley populate array which enables me to locate a game usin
the game number without having to implement a "search" function on th
games array

games[4325] = new GAME(4325, 201, 202, 'Baseball', 'MLB', ... );

).

games.sort();

... works but gives me a sort that I don't care about. Worse than tha
it "re-indexes" the array and now the first element is 0, the nex
element is 1, and so on. I can't locate a game by the gamenumbe
without implementing a search function.

so here comes a sort function (for the first problem, I deal with th
renumbering by creating a temp array, copying things over, sorting th
temp array and bringing everything back in the original array. nast
business).

function sortByRot( gameA, gameB )
{
return gameA.rotNum1 - gameB.rotNum2;
}

which I was hoping would let me do:

games.sort(sortByRot);

But in IE and Mozialla I get

"An exception of type "Microsoft JScript runtime error: Out of memory
was not handled." message. Now I'm facing the unpleasant task o
handling the sort myself.

Any help would be most welcome.

Regards,
Gamble
-
gamble

Jul 23 '05 #1
3 3968
gambler <ga************@mail.forum4designers.com> writes:

....
so a sparsley populate array which enables me to locate a game using
the game number .... games.sort();

.. works but gives me a sort that I don't care about.
What result do you want?

Sorting a sparse array will put all the defined elements before the
undefined ones, by design.

It will, obviously, change the order of elements, so they are (most
likely) no longer positioned where they originally were.
Worse than that it "re-indexes" the array and now the first element
is 0, the next element is 1, and so on.
Yes, that is what "sort" does on sparse arrays.
I can't locate a game by the gamenumber without implementing a
search function.
What did you want the sort function to do instead?
so here comes a sort function (for the first problem, I deal with the
renumbering by creating a temp array, copying things over, sorting the
temp array and bringing everything back in the original array. nasty
business).
Perhaps necessary, but hard to tell without knowing what you want.
Some times, it's enough to sort an array of indices, with an
appropriate comparison function.
function sortByRot( gameA, gameB )
{
return gameA.rotNum1 - gameB.rotNum2;
}
(maybe better named "compareByRot")
which I was hoping would let me do:

games.sort(sortByRot);
Sounds reasonable. It will still put all the defined elements before
the undefined ones..

But in IE and Mozialla I get

"An exception of type "Microsoft JScript runtime error: Out of memory'
was not handled." message.
It's unlikely that that specific error message was produced by Mozilla :)

How much memory do you have? How many elements are there in your sparse
array?
Now I'm facing the unpleasant task of handling the sort myself. Any help would be most welcome.


If you could show us the offending page, and say how you want the
data manipulated, then I'm sure we'll have a suggestion.

--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Jul 23 '05 #2
gambler wrote:
let's say you have:

var games = new Array();
games[gameNum] = new GAME(gameNum, rotNum1, rotNum2, ... );

(
I think you have to define a Constructor

function GAME(gameNum){
this.gameNum=gameNum;
for(a=1;a<arguments.length;a++){
this["rotNum"+a]=arguments[a]
}
}

Something like that.

or:

games[gameNum] = [gameNum, rotNum1, rotNum2, ... ]

Mick

so a sparsley populate array which enables me to locate a game using
the game number without having to implement a "search" function on the
games array

games[4325] = new GAME(4325, 201, 202, 'Baseball', 'MLB', ... );

).

games.sort();

.. works but gives me a sort that I don't care about. Worse than that
it "re-indexes" the array and now the first element is 0, the next
element is 1, and so on. I can't locate a game by the gamenumber
without implementing a search function.

so here comes a sort function (for the first problem, I deal with the
renumbering by creating a temp array, copying things over, sorting the
temp array and bringing everything back in the original array. nasty
business).

function sortByRot( gameA, gameB )
{
return gameA.rotNum1 - gameB.rotNum2;
}

which I was hoping would let me do:

games.sort(sortByRot);

But in IE and Mozialla I get

"An exception of type "Microsoft JScript runtime error: Out of memory'
was not handled." message. Now I'm facing the unpleasant task of
handling the sort myself.

Any help would be most welcome.

Regards,
Gambler

--
gambler

Jul 23 '05 #3
gambler wrote:
But in IE and Mozialla I get
You mean _Mozilla_?
"An exception of type "Microsoft JScript runtime error: Out of memory'
was not handled." message. Now I'm facing the unpleasant task of
handling the sort myself.

Any help would be most welcome.
This is an ActiveServer Pages error message, not a client-side one (which is
why it not only shows up in IE) and probably not related to scripting.

You should have posted the relevant snippets of your constructor code.
--
gambler


Signatures are to be separated with a line containing DashDashSpaceNewline.
PointedEars
Jul 23 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Snake Djip | last post by:
Hi, I have a problem with a home-made DLL used in an ASP environment. It is coded in VB6, apartment-threaded. The DLL returns a binary PNG stream (an image). I use it with ASP's...
0
by: John Bonds | last post by:
I have designed a multi-threaded application that manipulates images (CCITT Group 4 TIFF Images). I'm getting some strange behavior and I'm wondering if anyone else is seeing the same thing. I run...
0
by: lennart | last post by:
Greetings, the last three days I have started to get entries like: 2005-10-05-16.51.44.615996+120 I20328552G471 LEVEL: Warning PID : 11244 TID : 3006253568 PROC :...
10
by: schears | last post by:
Why? Running on windows 2000 with all updates, 2G Memory, 117G Hard Drive space available. This was not an issue until I added some code to two of my c files. Any suggestions? Thanks
1
by: Alex Chan | last post by:
Hi Group, I have written a window service wtih SAP.NET Connector which is to fulfil request from SAP client. SAP client will call a function exposed by my window service that has a big "out"...
3
by: comp.lang.php | last post by:
I have a counter that evokes the "Three Strikes You're Out" rule.. if you make more than N mistakes it auto-resets to avoid flooding $_SESSION with attempt after attempt, etc. However, the...
4
by: lawrence k | last post by:
I've a jpeg image that is 514k, which doesn't strike me as very large. Yet I'm running out of error when I try to resize it: Fatal error: Allowed memory size of 20971520 bytes exhausted (tried to...
16
by: saurabhnsit2001 | last post by:
The following program doesn't "seem" to print "hello-out". (Try executing it) #include <stdio.h> #include <unistd.h> int main() { while(1) { fprintf(stdout,"hello-out");
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.