Reply to Re: [PHP] too slow to unset big array (after mem fragment)

Your name:

Reply:


Posted by Richard Lynch on 01/20/05 00:44

Xuefer Tinys wrote:
> i have a big array with 20k elements, i have no problem building it,
> because the elements is recv from socket, i can socket_select() on 1k
> clients, read from them.
> i plan to unset the whole array every 1hour
> this is a not big problem when for a few times, it takes me 0.02 seconds
> but after many hours of running, unset will sometime takes 10 seconds.
> this is big problem because it's 1 unset() statement, and all incoming
> connection is blocked, the client may get connection time out
>
> summary:
> 1. one process, no fork (just has to be)
> 2. socket_select(), process each client's data simultaneously. some
> data will be put into array
> 3. each element value is /true/, and key is numeric(ip2long)
> $array[ip2long($ip)] = true;
> 4. fast to unset, but slow to unset after a few hours, with similar
> amount of elements

Just some ideas from a naive reader:

1. unset() more often
2. unset() only a portion of the elements of the array

You may even want to store a TIME element, and only unset() the "old"
items or something.

You may also want to, perhaps, put the unset() of older data inside your
socket listening/reading loop, so that you are unset-ing the really old
stuff as you read the new stuff, to always keep your array "small" in
size.

--
Like Music?
http://l-i-e.com/artists.htm

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация