What is the theoretical limit of characters in a string? I am planning a line of 5 million characters in length, will the interpreter stumble on such a line?
- checked eats long lines without losses and quickly :) - deivan_
2 answers
The theoretical limit is dictated by the allocator and bit depth. The practical limit is dictated by the fact that the client may be upset if the application tries to allocate 100G of memory :) 5 million characters is, roughly speaking, 10 megabytes of memory. What is it in our times?
The only danger may be waiting for you if you are going to form one character at a time - this will most likely work VERY slowly, so he will have to create a new line each time he adds a character to the line, copy the old one into it, and then add the character. This is terribly inefficient and can make the GC nervous if it is done too often.
- Thank you for your reply. so I want to pull the parser to the client side - it shut up on the server and as a result, the server generated an error. - deivan_
- Ooh ... if the server shuts up ... then things are bad .. are you sure that the client can do this in principle? Or maybe the server is done very inefficiently? - cy6erGn0m
- the server shuts up, because the hosting settings after 90 seconds give a time out. I rewrote php script, left only data retrieval without parsing. 3 million characters returned in 10 seconds, that's great. Now I sculpt a parser on the toad. - deivan_
As they say in many forums , the maximum length is not set by standards. But it is recommended not to put more than a megabyte.
And why do you need 5M characters? Maybe there are workarounds?
- a server sends data from security sensors in text form, the period for viewing such responses can be very long. I will parse this answer. - deivan_
- Why don't you parse all php? And view the results done using ajax. - ling
- php does not have time. At first, I was parsing on the server by requesting via Ajax, but the script falls off when processing large requests on timeout. - deivan_
- And if you try to curl'om get the data and write them to a file? And then run the second script - the parser. It turns out something like the separation of the task and the parser can do it. Or arrange with the programmers to the server to give only the data that is needed at a particular moment (by get-request or something like that). - ling