PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > php.general > Byte Size of an array
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Byte Size of an array

Réponse
 
LinkBack Outils de la discussion
Vieux 07/01/2008, 08h45   #1
Sancar Saran
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Byte Size of an array

Hello,

I just wonder to how can I find a memory size of an array.

Regards

Sancar
  Réponse avec citation
Vieux 07/01/2008, 10h55   #2
thib´
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Byte Size of an array

Sancar Saran wrote:
> Hello,
>
> I just wonder to how can I find a memory size of an array.
>
> Regards
>
> Sancar


Found this:
http://www.usenet-forums.com/php-gen...ize-bytes.html

Maybe out of date, but apparently there's no other way but to write it
yourself.

-thib´
  Réponse avec citation
Vieux 08/01/2008, 02h18   #3
Chris
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Byte Size of an array

Sancar Saran wrote:
> Hello,
>
> I just wonder to how can I find a memory size of an array.


<wild guess>
echo strlen(serialize($array));
</wild guess>

--
Postgresql & php tutorials
http://www.designmagick.com/
  Réponse avec citation
Vieux 08/01/2008, 14h18   #4
Eric Butera
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: [PHP] Byte Size of an array

On Jan 7, 2008 3:45 AM, Sancar Saran <sancar.saran@evodot.com> wrote:
> Hello,
>
> I just wonder to how can I find a memory size of an array.
>
> Regards
>
> Sancar
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


If you're wondering how much memory your array is taking up engine
wise you can do a few little tests. Of course you could do the echo
serialize form but that isn't going to tell you how much memory it
uses internally within the engine itself. Granted this might not
either, but it is at least a little closer.

var_dump(memory_get_usage());

$array = array(
1 => 'one',
2 => 'two',
3 => 'three'
);

var_dump(memory_get_usage());

Output:
int(53464)
int(53928)


Also Xdebug trace:
Version: 2.0.0
TRACE START [2008-01-08 14:13:17]
1 0 0 0.004355 51968 {main} 1
/Users/eric/Sites/blah.php 0
1 0 1 0.004833 52328
0.0052 23184
TRACE END [2008-01-08 14:13:17]
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 10h01.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,10759 seconds with 12 queries