Re: Multithreading for OOP PHP
| From: | Alessandro Pellizzari | Date: | Wed, 31 Oct 2012 11:39:53 +0000 |
| Subject: | Re: Multithreading for OOP PHP | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-319634@lists.php.net to get a copy of this message | ||
Il Wed, 31 Oct 2012 11:50:00 +0100, marco@behnke.biz ha scritto:
> The drawback of forking is the memory overhead. With every fork you take
> the same amount of memory which is not the case if you could use real
> threads.
No, it is not.
Forking in Linux uses COW (copy-on-write), so a freshly-forked process
occupies maybe 3-400 bytes of RAM. Only when writing on a memory
location, that location gets allocated.
There are advantages (it is more safe, as you can't overwrite other
processes' memory) and disadvantages (you can't simply read or write
memory to communicate between threads, but must use IPC).
But speed and memory consumptions are not an issue.
Bye.