473,394 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Cause of a large memory allocation difference on two different machines?

310 100+
I have just noticed a very large difference in memory usage for the PHP applications that I have developed for my company between my developmental machine and the "production" machine:

Development PC: PHP version 4.3.9 on a 32 bit using Linux Centos 4.5 as operating system.

Production machine: PHP version 5.1.2 on a 64 bit machine with Linux Novell Suse 10.1 as operating system.

I noticed this because I started to get memory limit exceeded errors on some page requests for one of the applications. Out of curiosity I inserted this line at several locations in the scripts to get an idea of the difference in memory usage between the two machines:

Expand|Select|Wrap|Line Numbers
  1. echo "memory = " . memory_get_usage(true) . "<br>";
  2.  
The table below shows an example output. The first column is from the 32 bit machine, the second is from the 64 bit machine, and the 3rd column is the difference. Each row represents a later location in the scripts.

Expand|Select|Wrap|Line Numbers
  1. PHP4        PHP 5    difference
  2. 3179336        2018056    1161280
  3. 4347824        2729504    1618320
  4. 5870144        3665760    2204384
  5. 5921784        3698664    2223120
  6. 6442704        4033856    2408848
  7. 8374136        5034368    3339768
  8.  
This large difference between the two machines really surprises me. Does anyone know what the primary cause may be? Is it because of the 32bit vs. 64bit architecture? Or is it because of the PHP4 vs. PHP5 versions?



[P:S: It may seem strange that I am developing applications with PHP4 that are intended to be deployed with PHP5. For the curious, here are the reasons: 1) the production server is new and I have not had a chance to upgrade the development machine, 2) so far it seems to work and 3) the new management at this small startup company has decided to outsource all IT related needs and purchase commercial software and my position has actually been terminated (I am currently looking for new work), hence there is no incentive to upgrade the development machine :) ]
Sep 15 '08 #1
7 2115
Atli
5,058 Expert 4TB
My guess would be the PHP version.

Although there is really no way to know without knowing what the code is doing.
Could be any number of things.

I don't see why the 32bit vs 64bit processors would cause this. The amount of data stored shouldn't be affected.
Sep 15 '08 #2
coolsti
310 100+
I am thinking that the 64 bit machine maybe by default is storing character data with a larger number of bytes per character. Maybe this is not something that the machine is doing because it is 64 bit, but because it is a different Linux installation or perhaps a combination of both.

Another explanation would be that the combination of this Linux and 64 bit architecture stores numeric data per default at a higher precision?

I just cannot see why the PHP5 over PHP4 would use so much more memory.

There are two large sinks of memory in my application. The first is due to the large amount of code that is included via require statements. I certainly do not include everything, but the classes that I have built up do contain a lot.

The second memory sink is due to the manner in which I build up a complex page with my own table, row and cell classes, and then echo all at once to the user at the end of the script. Pages showing complex process flows or distributions of wafers on chips result in large amount of HTML elements, all stored in objects until they are printed out at once.
Sep 15 '08 #3
Atli
5,058 Expert 4TB
I am thinking that the 64 bit machine maybe by default is storing character data with a larger number of bytes per character. Maybe this is not something that the machine is doing because it is 64 bit, but because it is a different Linux installation or perhaps a combination of both.
I doubt it stores the characters any differently. Each character set has a predefined size *per character* and both PHP versions should be using the same character set.
There would be no point in spending more than is needed.

Another explanation would be that the combination of this Linux and 64 bit architecture stores numeric data per default at a higher precision?
It could be. But, still, that doesn't make sense. It was the 64bit machine that had lower memory usage, right?

I just cannot see why the PHP5 over PHP4 would use so much more memory.
It could be that PHP5 is just designed to handle data differently.
Before PHP5, OOP wasn't really that good, and predicting the increase in OOP usage, and consequently the amount of files that need to be incuded, perhaps they improved the way PHP includes files and/or handles arrays (objects act much like arrays, so that would make sense).

But I don't really know. Just guessing here.
Sep 15 '08 #4
pbmods
5,821 Expert 4TB
Heya, Coolsti.

PHP 5 does have a problem with objects with recursive references (http://bugs.php.net/bug.php?id=33595). Looks like that won't be fixed until PHP 5.3.

I've heard that some people have memory problems after upgrading from 5.1 to 5.2, but I am not familiar with differences in memory usage between 4 and 5.
Sep 15 '08 #5
coolsti
310 100+
Thanks for the tips and replies!

To Atli, no, it is the PHP5 on the 64 bit machine which is using more memory.

I solved this issue by just increasing the allowable memory usage per page request. I would dig deeper into it if it wasn't for the fact that I am fired and management will probably eventually abandon the work that I have done here anyway. I will be here doing this still (although without much enthusiasm) until I find a new job or until the end of January, which ever comes first. So there is not much incentive for me to find out the real reason for the extra memory usage, be it due to architecture or PHP 5 bugs.

Interestingly enough, a major difference in memory usage can be seen in the first 3 rows of my above table, and these show_memory_usage outputs were placed in between sucessive require_only calls to load in needed classes. And here, the classes being loaded in are not really doing anything yet, but just becoming read in and made available. That is, class objects are not being created here.
Sep 15 '08 #6
Markus
6,050 Expert 4TB
for the fact that I am fired
That's a shame! I wish you all the best.

Good day.
Sep 15 '08 #7
Atli
5,058 Expert 4TB
To Atli, no, it is the PHP5 on the 64 bit machine which is using more memory.
Ahh ok. Isn't your table in the first post backwards then? It's shows PHP5 with the lower numbers. (... I think)

Anyways, good luck with the Job hunt.
Sep 15 '08 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: chris | last post by:
Hi all, I need to know, what is the difference between dynamic memory allocation, and stack allocation ? 1. If I have a class named DestinationAddress, when should I use dynamic memory...
7
by: mef526 | last post by:
I have had this problem for months now and it has been nagging me. I have a large project that has several C++ DLL's, one of them uses malloc / calloc / free for the other DLL's. I process very...
6
by: nekiv90 | last post by:
Greetings, Could someone confirm if the following reasoning is correct (64-bit DB2 on 64-bit AIX v5.3): ================================================================== For each connection...
62
by: ivan.leben | last post by:
How can I really delete a preloaded image from memory/disk cache? Let's say I preload an image by creating an Image object and setting its src attribute to desired URL: var img = new Image();...
2
by: nayannovellus | last post by:
As per my knowledge i know that when a structure is defined, no memory is assigned to its members but when a variable of that structure is declared memory is allocated and also this allocation takes...
81
by: Peter Olcott | last post by:
It looks like System::Collections::Generic.List throws and OUT_OF_MEMORY exception whenever memory allocated exceeds 256 MB. I have 1024 MB on my system so I am not even out of physical RAM, much...
8
by: Francine.Neary | last post by:
I'm experimenting with a program that manipulates a large matrix, i.e. a 2-deep array. I started by just allocating this in one go, but later it occurred to me that, as there are still some very...
5
by: Andreas Schmitt | last post by:
Hi, I recently worked on an open source project and tried to make on of the arrays they are using dynamically allocated to get rid of the max size. I used the realloc instead of the usual C++...
4
by: =?Utf-8?B?U2VyZ2Vp?= | last post by:
Dear staff Can I get your assistance with \3GB (LARGEADDRESSAWARE) switch in mixed mode process built by VS 2008, please? I have a mixed mode application: C# GUI calling native C++ DLL through...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.