473,789 Members | 1,929 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

310 Contributor
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 2148
Atli
5,058 Recognized Expert Expert
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 Contributor
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 Recognized Expert Expert
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 Recognized Expert Expert
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 Contributor
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_usa ge 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 Recognized Expert Expert
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 Recognized Expert Expert
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
8214
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 allocation to create object of that class ? 2. If it says "dynamic memory allocation", is it mean the following code : DestinationAddress* dest = new DestinationAddress(); // code 1
7
2177
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 large datafiles (100MB to 300 MB) that have more than 524,000 lines with 5 columns of numbers in text. I allocate 8 arrays with 524,000 or more doubles , and 10 arrays of 32,768 doubles. Is there a min size for malloc / calloc required to...
6
8121
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 to DB2 db, AIX will reserve a 64GB shared memory segment for buffer caching. So if there are connections to 3 different DBs, AIX will reserve a
62
17858
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(); img.src = ; Then I use the image a few more times by adding it into an Array object:
2
2415
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 place at runtime. Now my issue is that how is dynamic memory allocation different in case of structures(when variable of that structure is declared) and classes(where memory is allocated dynamically using new operator). whats the difference it both...
81
4576
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 less virtual memory. Are other people experiencing this same problem?
8
1932
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 old systems around where such a large allocation might fail, perhaps it would be better to split the allocation into many allocations, one for each row, to increase portability to legacy systems. The advantage I see is that the memory allocator...
5
6212
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++ new and delete because they asked me to stick to their "coding style" Well whatever..
4
5104
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 managed C++ wrapper. And I want to give the native C++ code access to large (>2G) addresses; but (if it’s possible) I do not want the managed code to use this extra GB of virtual memory. Questions are:
0
9656
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10177
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9969
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8998
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6750
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5540
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4078
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3677
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2898
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.