SimpleSHM
SimpleSHM copied to clipboard
Reserved block size could be too small
Hello Klaus,
I believe there is a problem with this line: $size = mb_strlen($data, 'UTF-8');
It returns the number of UTF-8 characters in $data. As UTF-8 is a multi-byte encoding, this number can vary from the actual length in bytes. This means the string would not fit into the reserved shared memory block.
The following fix would return the number of bytes: $size = mb_strlen($data, '8bit');
Best regards, gwyn
Yes I wanted to say the same thing. You need the number of bytes not characters. Also, only increase size if necessary. No need to shrink. Or put a threshold.