I have two Float32Arrays each one of which is 1.6*10^7 in length(floating point array). Using JS I retrieve them from server and add them element by element. My webpage stops responding and I get the following error message. Is there a way of handling huge arrays on client side without using JS or with JS?
Sign up
- Anybody can ask a question
- Anybody can answer
- The best answers are voted up and rise to the top
|
I don't have previleges to comment. So, I am adding it as an answer here. My browser (firefox 47) was able to set values for 50,000,000 elements of a Float32Array, one by one, under one second (It is not an insert/append though). It ran out of memory beyond that. I assume your bottleneck (browser warning) has more to do with slow fetching/processing of elements, few at a time, and keep the main browser thread busy. If you really need that much data to be fetched/processed/inserted, while at the same time let the browser remain responsive to the user, you may want to consider the multi-threading in HTML5 (or javascript libraries provided by Mozilla and others). It will help you in offloading the busy work into a background thread. |
|||
|
The answer is that you can't process all that stuff toghether, because is too much. You should rethink about what you are doing, some possible solution are:
|
|||
|
What you need is processing relative big data in a low memory, low performance environment. The general solution to this is using streams. In these streams you put only a single or a few chunks in the memory, process it, and free the memory. So you won't need a lot of memory and processing power to do the job. You need to stream the data from the server, create a processing stream on the client and display the data chunk by chunk, probably pixel by pixel. I guess you'll need a zooming algorithm, which should be able to use the same streams. If you have a working solution, then you can try to make it faster, e.g. by using multiple websocket connections, multiple display streams, a client side storage to cache data, data preparation on server side, web workers, etc... I think this will be a much longer project than you expected... Don't forget to share the solution with the js community! :-) |
|||
|