Is there a way I get the size of a PHP variable in bytes?

前端 未结 4 1930
梦如初夏
梦如初夏 2021-01-02 00:41

I currently have a PHP CLI script using Zend Framework extensively which seems to be using a ever larger amount of memory as it runs. It loops through a large set of models

4条回答
  •  走了就别回头了
    2021-01-02 01:07

    No. You are likely looking for memory that is not freed, e.g. you unlinked a variable or deleted a reference and the garbage collector did not yet release the associated block in memory.

    You could try Zend Server 5 (you need the commercial version though) to mem-profile your application. It has code tracing. I dont know if this would allow you to spot memory leaks though.

    Also see:

    • What's new in PHP V5.2, Part 1: Using the new memory manager
    • Memtrack (PECL)

提交回复
热议问题