B
B
BushaevDenis2019-05-20 11:39:40
PHP
BushaevDenis, 2019-05-20 11:39:40

How to work with a large file and limited RAM?

Let's say there is data that needs to be processed and made up of a large xml, let's say 150-200MB, and the RAM on the machine is only 2GB, which are clogged by 80-90% when the script is running.
What should be the algorithm of the program so as not to keep the entire file in memory, but also to work with the file normally through simple_xml lib?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
L
Lazy @BojackHorseman PHP, 2019-05-20
@BushaevDenis

read about xml_parse and SAX model

A
Adamos, 2019-05-20
@Adamos

Do not work with the file "via simple_xml lib", which is not intended for large files in principle, which is even mentioned on PHP.net
There you can easily find alternative libraries for working with XML that do not try to load it entirely into memory.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question