Do all the things like ++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatarSign Up
Memory limit set to 256MB, memory_get_usage() returns 85MB at max, wtf is going on here?
And now it reports 419MB somehow wut??!!
AleCx042304220dfucking hell man, I am legit interesting in the kind of stuff you is doing with this amd wondering if the configuration needs to happen somewhere else outside of the script itself. Are you doing something that would benefit from some concurrency? The thing is the higher your memory the less number of concurrent process you would get.
Let me get @C0D4
@AleCx04 I'm indexing a shit ton of data. The data alone is not that big, but the parsing process takes a bit more memory. I already had to create my own index format, because the resulting index couldn't be parsed into JSON with less than 1GB of memory :D It worked fine until I added thing that I call "byte map". Also it looks like, it's not really my mistake, but there are some issues with gc in PHP FPM.
C0D45914220dUnset() is exactly what you want.
Are you using variables as reference "&var" or value?
If your using values then each variable is copying and creating a new source of memory usage.
By reference is a single allocation of memory dropped into a containing method.
Unsetting or setting to null will clear it if you catch them all.
Otherwise increase the memory allocation limit in .ini to be able to utilise enough for what you are doing.
Or use ini_set("memory_limit", 500M);
For a temporary increase of memory,
You can use 0 and it will allow any memory resources but not always a good idea.
Care to share the code in a gist? I Can try and help.
@Lor-inc Unfortunately, it is supposed to run (at least temporarily) on shared hosting, so there is not much of a choice. Trust me, I wouldn't use PHP for this if I could.
@C0D4 Sorry, I can't share source with you as it is not my personal project. I am using &$var whenever possible. After some debugging, the main problem seems to be our database library. It returns array of objects, but these objects seems to be never garbage collected.
Fuck it, I will try to ask colleague tomorrow. Hopefully, he will come up with something...
hjk101238520dI think there might be a problem in the db lib. Never had an issue like this. Can't you ditch it?
arekxv96420dYou cant control the GC and you shouldn't try to. Just make sure that you dont have ANY live references to the variable you dont need and it will be freed on the next GC cycle.
Also PHP is doing copy on write so using &$var makes your code slower if you are not modifying the variable.