Memory usage by class files

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Colin McKinnon

    Memory usage by class files

    Hi all,

    I am currently working on a project which involves using a lot of code on
    each page. I'm currently refactoring with a view to performance and have
    discovered that when my app starts to include the class definitions it
    needs, the memory gets eaten up *very* rapidly - indeed, typically, the
    memory usage is TEN TIMES the size the class file occupied on the disk -
    note this memory usage is only as a result of require_once() not objects
    are instantiated, no code within the files has been run at this point.

    (there are some hard stats below)

    Has anybody else noticed this? Thought it a bit excessive? Found a more
    efficient way of building the code (should I consider 'compiling' the
    include files into a single one?). Unfortunately all the code is needed so
    while the larger files do have more than one class definition there doesn't
    seem to be much to be saved by using the autoloader.

    TIA,

    file mem used by require size on disk ratio
    form.inc.php 704912 81766 8.62
    widgets.inc.php 738800 57368 12.88
    linked.inc.php 80920 7286 11.11
    rawwidget.inc.p hp 74864 7497 9.99
    iterator.inc.ph p 123536 11451 10.79

    C.

  • Manuel Lemos

    #2
    Re: Memory usage by class files

    Hello,

    on 03/30/2007 08:21 PM Colin McKinnon said the following:
    Hi all,
    >
    I am currently working on a project which involves using a lot of code on
    each page. I'm currently refactoring with a view to performance and have
    discovered that when my app starts to include the class definitions it
    needs, the memory gets eaten up *very* rapidly - indeed, typically, the
    memory usage is TEN TIMES the size the class file occupied on the disk -
    note this memory usage is only as a result of require_once() not objects
    are instantiated, no code within the files has been run at this point.
    >
    (there are some hard stats below)
    >
    Has anybody else noticed this? Thought it a bit excessive? Found a more
    efficient way of building the code (should I consider 'compiling' the
    include files into a single one?). Unfortunately all the code is needed so
    while the larger files do have more than one class definition there doesn't
    seem to be much to be saved by using the autoloader.
    >
    TIA,
    >
    file mem used by require size on disk ratio
    form.inc.php 704912 81766 8.62
    widgets.inc.php 738800 57368 12.88
    linked.inc.php 80920 7286 11.11
    rawwidget.inc.p hp 74864 7497 9.99
    iterator.inc.ph p 123536 11451 10.79
    That is normal. PHP gets compiled into Zend Opcodes before executing.
    That is mostly what compiled PHP takes in RAM. It has nothing to do with
    classes.

    --

    Regards,
    Manuel Lemos

    Metastorage - Data object relational mapping layer generator
    ✅「官方网站」mk体育拥有各种免费又安全的资源,因为亚洲当中中国玩家人口基数的众多,mk体育创造了中国网络游戏的神话,全球首推免费在线点播体育直播。


    PHP Classes - Free ready to use OOP components written in PHP

    Comment

    • Colin McKinnon

      #3
      Re: Memory usage by class files

      Manuel Lemos wrote:
      Hello,
      >
      on 03/30/2007 08:21 PM Colin McKinnon said the following:
      >the memory gets eaten up *very* rapidly
      That is normal. PHP gets compiled into Zend Opcodes before executing.
      That is mostly what compiled PHP takes in RAM. It has nothing to do with
      classes.
      >
      Thanks Manuel. I was worried it might just be me!

      C.

      Comment

      Working...