Re: Fw: [PHP] PHP URL issues
| From: | Robert Cummings | Date: | Wed, 14 Mar 2007 16:23:56 +0000 |
| Subject: | Re: Fw: [PHP] PHP URL issues | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-250593@lists.php.net to get a copy of this message | ||
On Wed, 2007-03-14 at 17:15 +0100, Satyam wrote:
> ----- Original Message -----
> From: "Robert Cummings" <robert@interjinn.com>
> To: "Satyam" <Satyam@satyam.com.ar>
> Cc: <php-general@lists.php.net>
> Sent: Wednesday, March 14, 2007 4:49 PM
> Subject: Re: Fw: [PHP] PHP URL issues
>
>
> > On Wed, 2007-03-14 at 16:31 +0100, Satyam wrote:
> >> One more example of a questionable benchmark, not wrong but I wonder (as
> >> I
> >> was doing in my previous) whether it is really representative.
> >>
> >> There are two main ways to handle strings, one is to malloc exactly the
> >> required memory for each string and keep moving characters around from
> >> one
> >> chunk of memory to another. If you append a single character to a
> >> string,
> >> you would measure both, add their lengths plus whatever overhead your
> >> data
> >> representation requires, malloc that much memory, move the characters
> >> from
> >> each source and then free the memory occupied by the first.
> >>
> >> The other way to do it is to malloc memory in more or less fixed sizes
> >> and
> >> include in the header of your variable a length field.
> >
> > You forgot realloc().
> >
>
> Yes I did, but it doesn't matter that much. When asigning by blocks the
> best strategy is to keep all blocks the same size, or of a few assorted
> sizes, and link them in lists because blocks of different sizes end up
> fragmenting the memory too much and giving the garbage collector lots of
> trouble, if all blocks are of the same size, they are immediately reusable.
> Basically, if you are dealing with the memory yourself, assigning it,
> freeing it, collecting garbage afterwards and defragmenting, you won't
> resort that much to individual calls to the memory library functions, you
> just grab a big chunk and manage it on your own.
I realize that, but in the absence of your own management system (option
2 you mention) it is superior to using malloc(), memcpy(), and free().
Cheers,
Rob.
--
.------------------------------------------------------------.
| InterJinn Application Framework - http://www.interjinn.com
|
:------------------------------------------------------------:
| An application and templating framework for PHP. Boasting |
| a powerful, scalable system for accessing system services |
| such as forms, properties, sessions, and caches. InterJinn |
| also provides an extremely flexible architecture for |
| creating re-usable components quickly and easily. |
`------------------------------------------------------------'