473,513 Members | 2,575 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

The memory footprint of some global vals

Hi,

Just like phpBB i have a fairly large language section.

For those of you who do not know it there is a global array variable $lang
and it contains translations of many word used all over the place.
For example
$lang['hello'] = 'Hello';
$lang['bye']='Goodbye';
....and so on

but that array contains a few hundred entries, most of them are not used in
the everyday use of the site.

How big of a problem could that be in terms of memory? Does php load that
array everytime a new user queries a page or is the array shared between all
the processes?
Would there be a better way of doing it that would not be so heavy on the
memory?

Regards.

Sims
Jul 17 '05 #1
4 1910
if it is in an include file, chances are the files is in cached in ram, and
generaly speaking, the data is not a shared memory object, it can be one
memory object shared by all proccesses, but there is a good chance its not.

to ease the load, in either case just put $100 in memory and call it a day.

--
Mike Bradley
http://www.gzentools.com -- free online php tools
"Sims" <si*********@hotmail.com> wrote in message
news:c0*************@ID-162430.news.uni-berlin.de...
Hi,

Just like phpBB i have a fairly large language section.

For those of you who do not know it there is a global array variable $lang
and it contains translations of many word used all over the place.
For example
$lang['hello'] = 'Hello';
$lang['bye']='Goodbye';
...and so on

but that array contains a few hundred entries, most of them are not used in the everyday use of the site.

How big of a problem could that be in terms of memory? Does php load that
array everytime a new user queries a page or is the array shared between all the processes?
Would there be a better way of doing it that would not be so heavy on the
memory?

Regards.

Sims

Jul 17 '05 #2
if it is in an include file, chances are the files is in cached in ram, and generaly speaking, the data is not a shared memory object, it can be one
memory object shared by all proccesses, but there is a good chance its not.
to ease the load, in either case just put $100 in memory and call it a day.


Thanks, but it is not a case of money, more a case of me wanting to learn
how it works.
If i can prevent the 'over' use of memory that would be better programming i
think.

It is a include file.
I just wanted to know the inner workings of php and how global variables are
affecting my memory.

BTW i do not use $, (NZ, CAN, US or AUS whichever you were referring to).

Regards,
Sims
Jul 17 '05 #3
"Sims" <si*********@hotmail.com> wrote in message
news:c0*************@ID-162430.news.uni-berlin.de...
if it is in an include file, chances are the files is in cached in ram, and
generaly speaking, the data is not a shared memory object, it can be one
memory object shared by all proccesses, but there is a good chance its

not.

to ease the load, in either case just put $100 in memory and call it a

day.


Thanks, but it is not a case of money, more a case of me wanting to learn
how it works.
If i can prevent the 'over' use of memory that would be better programming

i think.

It is a include file.
I just wanted to know the inner workings of php and how global variables are affecting my memory.

BTW i do not use $, (NZ, CAN, US or AUS whichever you were referring to).

Regards,
Sims


sorry, I was not insuating it was a case of money, my apologies. (oh, and
the $=US, sorry, I forget this is read all over the world)

With scripting, it is a slightly differnt animal compared to
compiling/binary programming. some times in scripting it is the easyier
route that shall prevail.

Now I do undstand your curiosity.

It is possible with php to create a shared memory object (works like a file)
that would hold all items in your lang definitions, then this can be
available to all proccess.

But becouse we are dealing with more than just the PHP interpeter, such as
the OS, file system, I have found that included files that are used in every
single script (such as variable definitions/configs) tend to get cached by
the OS into memory, granted, they go from their cached copy to a new copy
for each process, it is rather fast. Also with less overhead on the
programming side of the fence. With the expense of a bit more memory, it
just be comes an include, but with it as as shared memory object, you then
have code to access such object, and a bit more complexity.

It is my opinion, that sometimes, an easier to read/modify script is a faste
r/econamical slotution. Now I am not advicating sloppy coding skills, In
fact, I come from a background where I would have to cram in an OS,
aplication, and data into a 2K ROM chip, not fun, but made for some crafy
coding (whitch I do miss sometimes)

Well, sorry to ramble on, I know I probly didn't answer your question, but I
hope I brought up some stuff to ponder.

--
Mike Bradley
http://www.gzentools.com -- free online php tools
Jul 17 '05 #4

Regards,
Sims
sorry, I was not insuating it was a case of money, my apologies. (oh, and
the $=US, sorry, I forget this is read all over the world)


No worries, :)

It is possible with php to create a shared memory object (works like a file) that would hold all items in your lang definitions, then this can be
available to all proccess.
But would it really be better.

But becouse we are dealing with more than just the PHP interpeter, such as
the OS, file system, I have found that included files that are used in every single script (such as variable definitions/configs) tend to get cached by
the OS into memory, granted, they go from their cached copy to a new copy
for each process, it is rather fast. Also with less overhead on the
programming side of the fence. With the expense of a bit more memory, it
just be comes an include, but with it as as shared memory object, you then
have code to access such object, and a bit more complexity.
I see,

It is my opinion, that sometimes, an easier to read/modify script is a faste r/econamical slotution. Now I am not advicating sloppy coding skills, In
fact, I come from a background where I would have to cram in an OS,
aplication, and data into a 2K ROM chip, not fun, but made for some crafy
coding (whitch I do miss sometimes)
I also had the pleasure of putting 16k code on the chip of some credit card
companies.
A similar challenge in itself.

Well, sorry to ramble on, I know I probly didn't answer your question, but I hope I brought up some stuff to ponder.
You did, thanks.

--
Mike Bradley


Sims
Jul 17 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3313
by: Mike Peretz | last post by:
I am trying to optimize my C# program, but no matter what I try the application keeps eating memory. I verified all the references and even got special software to count references. I made sure all the reference count reaches zero for all the objects that are no longer used. I also call Dispose as much as possible. Regardless, the memory is...
2
460
by: tomvr | last post by:
Hello I have noticed some 'weird' memory usage in a vb.net windows app The situation is as follows I have an app (heavy on images) with 2 forms (actually there are more forms and on starting the app I load some things into memory for global use of the app but I'll use only 2 starting forms to explain the situation) situation 1 start app...
6
3235
by: Tom | last post by:
We have a VERY simple .NET C# Form Application, that has about a 23MB Memory Footprint. It starts a window runs a process and does a regular expression. I have done a GC.Collect to make sure that, no memory is lying around. GC reports only 84k of allocations. Starting 5-10 of this apps is going to start taking a considerable amount of memory....
2
2938
by: assi | last post by:
Hello all We are developing a large dotnet application, which includes ~ 120 assemblies. (total size of all binaries is ~ 20MB). Our application also references the following dotnet assemblies: System,System.XML, System.Windows.Forms, System.Drawing, System.Data, System.Design. We use dotnet framework 1.1 During initialization, the...
10
399
by: Segfahlt | last post by:
I have a fairly simple C# program that just needs to open up a fixed width file, convert each record to tab delimited and append a field to the end of it. The input files are between 300M and 600M. I've tried every memory conservation trick I know in my conversion program, and a bunch I picked up from reading some of the MSDN C# blogs, but...
8
1853
by: Bob Dufour | last post by:
We got a windows form application that we wrote in VB.Net. Essentially its a manager for a list of persons and their contacts and some other info about the persons. No rocket science but lots of textboxes and comboxes to use lookup lists, some tab controls allow viewing of data about a person in logical groupings. We find that as we load...
4
1629
by: ok | last post by:
I have the following code: void foo(void) { const int array = ....; // do stuff with array } I mostly use code like this so my program doesnt waste memory because array
0
883
by: Benjamin Rutt | last post by:
I have a bunch (e.g. 40) of tkinter Text objects in a gui on a linux machine, tracking monitoring info per host. They accumulate up to 500MB of text data (according to /bin/top) over time reading from sockets. I want to release this memory first by clearing all the text contents, but keeping the Text objects in the GUI, via a callback like:...
9
4198
by: jeungster | last post by:
Hello, I'm trying to track down a memory issue with a C++ application that I'm working on: In a nutshell, the resident memory usage of my program continues to grow as the program runs. It starts off at a nice 4% of memory, then slowly grows up to 50% and beyond. This translates to around 2 gigs of physical memory, and that's really way...
0
7270
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...
0
7397
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
7565
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...
1
7128
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
3255
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3242
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1612
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
1
817
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
473
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...

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.