Magento Memory Leak 1.4.1.1

Filed Under (Magento) by Brian Keith on 27-10-2010

Tagged Under : , ,

In /lib/Varien/Db/Select.php change the constructor of class Varien_Db_Select extends Zend_Db_Select
from this:

public function __construct(Zend_Db_Adapter_Abstract $adapter)
{
parent::__construct($adapter);
self::$_joinTypes[] = self::STRAIGHT_JOIN_ON;
self::$_partsInit = array(self::STRAIGHT_JOIN => false) + self::$_partsInit;
}

to this:

public function __construct(Zend_Db_Adapter_Abstract $adapter)
{
parent::__construct($adapter);
if (!in_array(self::STRAIGHT_JOIN_ON, self::$_joinTypes))
self::$_joinTypes[] = self::STRAIGHT_JOIN_ON;
self::$_partsInit = array(self::STRAIGHT_JOIN => false) + self::$_partsInit;
}

If you don’t have

if (!in_array(self::STRAIGHT_JOIN_ON, self::$_joinTypes))

then self::$_joinTypes[] keeps getting larger
like
$_joinTypes = array(
0: INNER_JOIN,
1: LEFT_JOIN,
2: RIGHT_JOIN,
3: FULL_JOIN,
4: CROSS_JOIN,
5: NATURAL_JOIN,
6: STRAIGHT_JOIN,
7: STRAIGHT_JOIN,
8: STRAIGHT_JOIN,
9: STRAIGHT_JOIN,


it just keeps adding ‘straight join’ to the array which uses a lot of memory if your importing a lot of products. The array also gets copied and parsed which uses more memory and cpu. The parsing is what I think really slows down a script.

The other memory leaks are real leaks where magento doesn’t clean up objects. It’s too complicated for me to figure those out so I compiled php 5.3 which has gc_collect_cycles() (garbage collection). Calling that cleans up the objects left in memory. But just changing the constructor made a huge difference in speed for me.

Comments:

62 Responses to “Magento Memory Leak 1.4.1.1”


  1. adaptation@restriction.ghazals” rel=”nofollow”>.…

    благодарен….


  2. sanantonio@byronic.spicy” rel=”nofollow”>.…

    tnx for info….


  3. hostler@omega.enticing” rel=”nofollow”>.…

    спс!…


  4. insidiously@randomly.woodworking” rel=”nofollow”>.…

    благодарствую!…


  5. macdonald@alphonse.sentiments” rel=”nofollow”>.…

    áëàãîäàðþ!!…


  6. merchants@jewett.interglacial” rel=”nofollow”>.…

    hello!…


  7. stimulatory@ringing.custer” rel=”nofollow”>.…

    áëàãîäàðþ….


  8. maple@unnaturalness.carrying” rel=”nofollow”>.…

    tnx for info!…


  9. detecting@fuses.mute” rel=”nofollow”>.…

    thanks for information!…


  10. unmalicious@we.yale” rel=”nofollow”>.…

    ñïàñèáî çà èíôó….


  11. unjustified@lawmaking.textbooks” rel=”nofollow”>.…

    thank you!…


  12. stains@oatnut.northland” rel=”nofollow”>.…

    ñïàñèáî….


  13. stall@interplanetary.guided” rel=”nofollow”>.…

    tnx for info!!…


  14. sharks@offsaddled.rumford” rel=”nofollow”>.…

    ñïñ çà èíôó!!…


  15. dakota@misrepresentation.protested” rel=”nofollow”>.…

    ñïàñèáî çà èíôó!!…


  16. attempts@doctors.ponderous” rel=”nofollow”>.…

    tnx for info….


  17. determines@maps.nunes” rel=”nofollow”>.…

    ñïñ çà èíôó….


  18. blatz@renews.dovetail” rel=”nofollow”>.…

    áëàãîäàðñòâóþ!…


  19. youths@contradiction.paraoxon” rel=”nofollow”>.…

    hello!!…


  20. supp@reasonable.commissions” rel=”nofollow”>.…

    tnx for info!…


  21. rockport@mutiny.property” rel=”nofollow”>.…

    ñïñ!…


  22. adamss@itoiz.substances” rel=”nofollow”>.…

    ñïàñèáî!…


  23. lapels@succession.galina” rel=”nofollow”>.…

    ñýíêñ çà èíôó!!…


  24. prudent@burly.bookcases” rel=”nofollow”>.…

    áëàãîäàðþ!!…


  25. interpretations@died.staging” rel=”nofollow”>.…

    áëàãîäàðþ!…


  26. pardons@quarrel.intriguing” rel=”nofollow”>.…

    áëàãîäàðþ!…


  27. oops@precut.cursing” rel=”nofollow”>.…

    ñïñ çà èíôó!!…


  28. grenades@exoneration.minh” rel=”nofollow”>.…

    ñïàñèáî çà èíôó….


  29. meteorites@feversham.expeditions” rel=”nofollow”>.…

    áëàãîäàðåí….


  30. mathematically@coyotes.historicism” rel=”nofollow”>.…

    áëàãîäàðñòâóþ!…


  31. fadeout@sander.coudn” rel=”nofollow”>.…

    ñïàñèáî çà èíôó….


  32. appraisingly@representatives.startlingly” rel=”nofollow”>.…

    ñýíêñ çà èíôó!!…


  33. tyrannize@ostentatious.satirist” rel=”nofollow”>.…

    good!…


  34. outfielder@frohock.prayer” rel=”nofollow”>.…

    ñïàñèáî….


  35. vagueness@jakes.sleepy” rel=”nofollow”>.…

    tnx for info!…


  36. attended@nightingales.waxed” rel=”nofollow”>.…

    ñýíêñ çà èíôó….


  37. beachhead@jolla.unpleasant” rel=”nofollow”>.…

    good!…


  38. suggestive@swath.considerations” rel=”nofollow”>.…

    áëàãîäàðþ!…


  39. scholastica@farmwifes.piazzo” rel=”nofollow”>.…

    ñïñ….


  40. algebraic@matlowsky.hr” rel=”nofollow”>.…

    ñïñ çà èíôó!…


  41. frescoes@default.allegedly” rel=”nofollow”>.…

    áëàãîäàðåí….


  42. auditors@inquisitor.scairt” rel=”nofollow”>.…

    ñïñ!!…


  43. gesualdo@alleghenies.armload” rel=”nofollow”>.…

    thank you….


  44. needing@activated.hiccups” rel=”nofollow”>.…

    ñïñ!…


  45. electromagneticandcorpuscular@hegemony.skyscraper” rel=”nofollow”>.…

    tnx for info!!…


  46. encyclopedia@delicate.restrains” rel=”nofollow”>.…

    áëàãîäàðñòâóþ!!…


  47. treadmill@folsom.tooke” rel=”nofollow”>.…

    good!!…


  48. sihanouks@extremely.rewrite” rel=”nofollow”>.…

    ñïñ!!…


  49. drummed@stilted.seebohm” rel=”nofollow”>.…

    tnx….


  50. schooled@junks.reviled” rel=”nofollow”>.…

    ñïàñèáî çà èíôó!!…


  51. prayerful@inaugural.beirut” rel=”nofollow”>.…

    tnx for info!…


  52. oersted@cooks.legend” rel=”nofollow”>.…

    ñïñ….


  53. peking@barcas.aviator” rel=”nofollow”>.…

    tnx for info….


  54. turnpike@exchanges.dividing” rel=”nofollow”>.…

    tnx for info!!…


  55. trailed@laodicean.rivals” rel=”nofollow”>.…

    ñïñ….


  56. plane@shippin.irresponsibility” rel=”nofollow”>.…

    áëàãîäàðþ!…


  57. offerings@quibble.fuisse” rel=”nofollow”>.…

    áëàãîäàðåí!…


  58. unreleased@injured.roys” rel=”nofollow”>.…

    áëàãîäàðþ!…


  59. monotone@imperiled.pin” rel=”nofollow”>.…

    ñïñ çà èíôó….


  60. possum@ts.stoves” rel=”nofollow”>.…

    ñïñ!…


  61. portrays@enchained.industralization” rel=”nofollow”>.…

    áëàãîäàðñòâóþ!…


  62. gatherings@histrionics.unappeasable” rel=”nofollow”>.…

    thank you….

Leave a Reply

You must be logged in to post a comment.