Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    PHP




Form Has Memory


I'm trying to fill form fields with values from a mysql record using
php. The problem is that when I move to a new record, the form still
displays the old data! The html source is updated but the previous
record is still displayed even after hitting refresh. Running the code
in a new window shows the correct result until I move to a new record.




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
FORM MEMORY ON PRESSING BACK BUTTON
Do most browsers retain form fillup memory of previous page ? That is
when the user presses back button, the forms on the previous page come
up filled.

100KB Image That Takes Up 2mb Of Memory Uses Up All 8mb Of Memory - Help!
I have an image that's only 100K in size, and I am working with 8mb of
memory. If I do this:

Code: ( php )

Adding "memory" To An Html Form Using Php
Is there anyway to retain the inputed information in a form?

Example:
I have 3 forms. (I am passing the variables from form to form using hidden variables, and the echo statment, thats not the problem) the final form contains the users name, address info etc. After the user fills out that form they come to a screen with all of there outputed info. I ask if there are any mistakes, if there are, the user either hits a back button or maybe a 'fix, edit' button. How do I retain the info on the form, so when the user does try to fix the error, all his info is still in place in the text fields in the form?

Also, does anyone know of a 'canned' form validation script.

PHP Memory
I've using PHP 3.0 to program a database study using a database in MySQL. The task at the moment is to go through the database of 1000 records and check all the datas valid. The problem is, the program gets to about record 500 and then just stops without any error message. I believe it to be a memory problem, but with 128Mb of RAM, I also believe to be suitable.

Memory
This problem may be a server problem, but I'll start by asking here. I have written a script for uploading images. When i attempt to upload images with a certain filesize, i get a fatal error. I tried with different filesizes, and narrowed down the approximate borderline to between 30k and 40k.

A 76K .jpeg file works fine.

A 1.7M .jpeg gives the error:
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 2608 bytes) in /Users/test/Sites/cms/lib/functions.inc.php on line 1050 Code:

Memory Management
I've ran into a problem with my MySQL Class. Otherwise a very useful and easy tool, but when you get to handle large amounts of data with it, it will slow your site down significantly. It contains three functions, from which the SelectAll() is the troublesome 'cause it returns all results of a query. What it basicly does is it piles all data inside array. Each result is an array, inside the main array. This makes it easy to go through with loops.

But imagine what happens if I get 10000 results. I've tried to optimize it and basicly the SelectAll() is only a few lines long. Still it slows down. I've tried to search for articles about the issue but nothing, for this kind of thing, has come up.

In Memory Database
Anyone know of an extension that is an in memory database?

I dont want to create any files on disk (nor install a database engine)
but have an object/variable that points to a database and tables all in
memory. Then to be able to do simple select, insert, deletes and
updates.

This could be easier than using arrays for certain tasks.

Something like this would be nice. E.g.

$db->new memDB('myDB');
$tbl=new memTBL('names')
$tbl->addCol('fname','CHAR',20);
$tbl->addCol('lname','CHAR',20);
$tbl->addCol('dob','DATE');
$tbl->addKey('fname');
$tbl->addKey('lname','fname');
$db->addTable($tbl);

$db->exec("insert into names ('fname',lname','dob') values
('John','Doe',Ƈ/1/1900')");
$db->exec("select * from names where fname='John' order by lname");

Memory Leak
We have found a memory leak on a php server after executing a php/mysql
application. The configuration is php 4.3.1 + mysql on windows server
2000 with IIS.

Does the memory leak come from the php application itself (ie. a bug on
the php developed scripts)?

PHP Memory Management
I'm new to PHP programming (coming from C++); and all is well, except when
it comes to memory management. Particularly, with passing objects/arrays in
and out of functions. I've had so many unexpected results because of this
feature, that I'm almost pissed off, almost.

Things like, I have a class, with some callbacks (which default to functions
inside the class). But when the default functions were called, $this
couldn't see the values of the member variables. I found that my calling
array($this, "fun") (for use in a call to call_user_func) was creating a
copy of $this and thus it was a copy of the variables. Fixed with a $cb =
array(); $cb[0] = &$this; etc...

Later, with more problems, I found that $x = new y; made two copies (I've
assumed from the testing I'd done). One where it calls the constructor, and
then one when it copies it into $x. Fixed with a $x = &new y; (I consider
myself lucky to have discovered this as it could very easily have gone
unnoticed, had I not been setting up a reference to this in the constructor)
Which makes me worry that there are other places I don't know about!

....and lots more of course...

I guess with a little more care, it will be obvious where a problem exists,
but as I am a newbie, I know it will continue to destroy me.

Are there any tools or memory management functions that will allow me to see
exactly how many copies of various objects/classes/strings I have. Or a way
to dump a memory allocation when it happens or anything. I'm fearful that
there may be millions of copies of my classes and such that I won't know
about until it gets released - and two users go to the web site at the same
time and cause the server to run out of memory.

C++ is so much easier, I know exactly what memory is allocated, when and
where, and when it will be destroyed. Whoever invented garbage collection
and all that; a can of comeuppance upon them (not the good kind).

Memory Leak ?
I am using PHP 4.3.9 in Linux 2.4.20-37. When I run this program:

echo "Memory Usage: " . memory_get_usage() . "";
for($i=1;$i<1000;$i++){
$dom = domxml_open_file("xml/ht_players.xml");
unset($dom);
}
echo "Memory Usage: " . memory_get_usage() . "";

I get the this results:

Memory Usage: 15336
Memory Usage: 795544

Why memory usage grow so much if I use unset($dom)?. There is anyway
to prevent/fix this?

8 Meg Memory Limit In PHP 4
I'm getting frustrated with the 8 meg memory limit in PHP 4 and PHP's
inability to handle files of even moderate size. Below you'll see the
error message I'm getting, and below you'll see the function that is
generating it. Is there anyway to keep a log file without running into
PHP's memory limits?

Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to
allocate 476934 bytes) in
/home/www/krubner/ppUtilityCode/incrementSiteHistory.php on line 77

<?php
function incrementSiteHistory() {
// 03-22-04 - we want to keep a site history in a flat file that
belongs to this software, and which
// therefore, is not effected by the vagaries of web hosting
companies and their policies. Most
// web hosting companies delete the Apache site log each week, so we
can rely on that as a
// long term source of site history.
$controllerForAll = & getController();
$sessionObject = & $controllerForAll->getObject("McSessionInfo", " in
incrementSiteHistory().");
$pageInfoObject = & $controllerForAll->getObject("McPageInfo", " in
incrementSiteHistory().");
$resultsObject = & $controllerForAll->getObject("McResults", " in
incrementSiteHistory().");

$username = $sessionObject->getUserName();
$pageId = $pageInfoObject->getPageId();
$page = $GLOBALS["page"];
$category = $GLOBALS["category"];

// 04-22-04 - we need to get the config so we can use
$pathToNeededFiles as a prefix on the file name.
$config = getConfig();
$pathToNeededFiles = $config["pathToNeededFiles"];

$fileName = $pathToNeededFiles;
$fileName .= "mcLogs/siteLog.php";
if (file_exists($fileName)) {
$fp = fopen($fileName, "r+");
} else {
$fp = fopen($fileName, "w+");.......

Memory Leak In PHP
I've heard that the Zend Engine's garage collector is not perfect, so
can someone demonstrate how to create a memory leak in PHP?

Cgi Vs Mod Thread Memory Used
Has anyone compared the amount of RAM a CGI version of PHP consumes per process compared to the amount an Apache thread takes when running as a module?

I have a project where start up time for a script is not an issue but the amount of RAM it will take is, as several processes will be running simultaneously and for extended periods. BTW, this will be run on UNIX.

Shared Memory
i've some questions about the shared memory functionalities. first, is there a real difference between shm_* and shmop_* functions? ... the documentation says old (shm_*) and new (shmop_*) functions (called "renamed" in changelog of php).

mainproblem - our provider doesn't compile '--enable-sysvsem' '--enable-sysvshm' which i need for the shm_* functions i think ... but he has compiled '--enable-shmop' ... i can use the shmop_* functions, but they're really different from the "old?" shm_* functions ... one problem /-> i cannot use arrays (only strings) ... or is there a trick how i can manage that?

Explode And Memory
When using explode on a string, you split it up into an array right? Does that array stay in the RAM, or in some weird browser memory/cache? And either way, do I have to empty that memory myself?

How Much Memory Does My Script Use?
My Hosting company is saying that I am using too much memory on the VPS
and that I should upgrade.

I am currently running at 65%-75%, (according to WHM).

It does seem a bit high, but I cannot see what could be using a lot of
memory. I have MySQL 5 and and php 4.4.
Is there any PHP code that I could use to 'check' how much memory a
script is using to run so that I could flag the problem ones?

How would you identify what process is taking large amount of memory?

Clear Memory
I'm having a strange problem in a script I wrote. Some variables that begin as input names, maintain their value for a long time after they have been initially used.

Basically what happens is something is input in one form under the name "title", and when I have a field with the same name in another form, the new field uses the value of the old one. This is really annoying and I was wondering if anyone could explain this.

GD Fns And Memory Leak
I have a class for manipulating images, making thumbnails etc. When it
runs
under Apache, I find that each process is using up about 50M more than
when
it started.

I have three lines of code that show a similar problem:

$imNew = ImageCreateTrueColor(3000,2000);
ImageJPEG($imNew, '', 75);
ImageDestroy($imNew);

Without the ImageJPEG line, a newly created Apache process goes up by a
few
100K, which I can understand. Add in the ImageJPEG line and it goes up
about
30M. Surely the memory should be released when the image resource is
destroyed.

I have Apache 2.2.0 and PHP 4.4.1 running under Apache. Has anyone else
seen
this? (It also occurs under Apache 2.0.54 and PHP 4.4.0)

Memory Issues
i have alot of raw data (e.g. x-coords, y-coords) stored in text files,
and i'm reading from those text files so that i can use that data to
create graphs. i'm currently using the image_graph package
(http://pear.php.net/package/Image_Graph/) to create these graphs. the
problem i'm having is that my memory usage just after creating less
than 5 graphs is already at 3.5 megs, and i need to create over 100
graphs. so, memory usage is a big problem. does anyone have any
suggestions on how alleviate this problem?

Increasing PHP Memory!
I recently installed Moodle onto one of my websites. It spoke about increasing my PHP memory up to 16MB. But how do it do this?

I came across this article:

Memory Leaks?
I've got some code that constantly updates a table on my web page. There is an update every 250 milliseconds. The problem is that my memory usage for IE is outrageous after about 5 minutes of running (roughly 600 mb of memory used). I'm not sure if this is a problem with my PHP script that pulls the data or the use of Sajax. Code:

Memory Handling
i have a php script thats can run out of memory (basically the user overloads it), Now i plan to fix this but for now i wanted to manage the error,

in my script i added
<?php echo memory_get_usage()."-".memory_get_peak_usage(true)."<br />"; ?>
into the loop and basically wanted to either handle the error or break the loop, but i can't seam to work out either
1. how to find the max amount of memory i can use
or
2. capture the error.

the error that displays is
Quote578508-786432
1631084-6291456
2681008-11010048
3731308-15728640
4781348-20447232
5831764-25165824

Fatal error: Allowed memory size of 25165824 bytes exhausted (tried to allocate 6297585 bytes) in /home/devico/public_html/class/UserExt.inc.php on line 150

Memory Usage & Php
today i have written a script (using the safox api) to convert data from a mysql database to several xml files.

we re talking about quiet alot of data. When i run the script it goes incredibly fast, it creates like 650 xml files in 20 seconds (while with my earlier script not using sofax it took like 20 minutes for the same amount of data).

anywayz, i got a new problem now

after it ran 1 minute and processed about 1200 xml files, i get the next error:

Fatal error: Allowed memory size of 524288000 bytes exhausted (tried to allocate 52 bytes) in C:wwwxmlswitchclassessafox_g.cls.php on line 767

i know what it means, and i know that i could solve the problem with messing around with ini_set or just change the max memory size in php.ini, but that is what to avoid doing.

do you guys got any tips on saving memory usage while using php?
is there something like .net's "garbage collection" in php?
or is there any other way to save memory ?

Memory Or Time?
Im trying to use curl to stream flv youtube video through a web proxy..i get it..but only a part if the video is too long (no more of 2 minutes ca)..any idea? some strange htaccess settings about memory or time?

Way To Erase An Array From Memory?
I'm going through a for loop and trying to assign new values to an array and then display the contents of the array each time through the loop. I'm redeclaring the array each time through to assign the new elements:

$final_list = array_unique($temp_list);
sort($final_list);

for($count=0; $count < count($final_list); $count++)
{
echo "final_list[$count]: $final_list[$count] <BR>";
}

and that is the extent to which I'm using the array each time through. However, upon viewing the echo results, each time through the loop the array contains the elements from the previous version of the array. If the new loop assigns a new value to the array, if it's not already there, then it adds it to the array, but keeps the old values. My basic question is this: do I need to deallocate memory (erase) the array each time through the loop? I've read the manual extensively and can't find an answer anywhere. Thanks a ton for any help!

Shared Memory Limit?
I'm using PHP 4.2.2 on RH9 Linux (with Progeny.com updates, in case
you're wondering). I was using shared memory (shm* API) a great deal
in my web applications because I have 1GB of RAM on this system. By
using shared memory, I can optimize web pages a little by not having
to hit the database every time I want to regurgitate a somewhat-static
reference table.

You may be familiar with the API that looks like this:

$key = 'My Key'
$value = 'My Value'
$app = 'lovelyapp' //lovelyapp would be the fake name of my web app
$key = $key . &#391;.5' //1.5 was the version of my web app, to provide
uniqueness
$segment_key = abs(crc32($app . $key));
$segment_size = 1024;
$segment_perms = 0600;
$shm_id = shm_attach($segment_key, $segment_size, $segment_perms);
shm_put_var($shm_id, $app . $key, $value);
shm_detach($shm_id);

This was working rather beautifully for me until I started messing
with the &#391;.5' literal. The reason, I suspect, was that I had been
using the app (without a bounce of httpd or entire server) and storing
stuff in shared memory with keys of 1.3, 1.4, 1.5, and 1.51 as my app
went through various revisions. This allowed different versions of the
app to simultaneously exist on the same web server and have an
exclusive section of shared memory.

I didn't think I was storing a tremendous amount of stuff there --
perhaps no more than 1MB per shared memory section (determined by
$segment_key).

Finally, *KABOOM* my web app died with the error "Not enough space on
device" and pointed out the error was on the line where I used
shm_attach().

So, I thought -- no problem -- no one using the app this late, so I'll
just bounce the web server (httpd). I did and the error still occured.
I thought, okay, clear my local browser cache and try again. Nope --
still occurred. I tried to bounce httpd again and even go straight to
the web server itself and see if a web page would have the same error.
Yep -- it had the same error no matter what I did.

I had no choice but TO REBOOT THE ENTIRE LINUX WEB SERVER. This
definitely cleared up the problem and I've now hammered on that server
for awhile now with the web app and all looks well.

What's your diagnosis? And, why didn't bouncing httpd clear it up
since Apache spawns PHP as a child process and PHP spawns shared
memory as a child process --

Keeping An Array In Memory
I'm afraid I don't know PHP well enough
to figure this out.

What I would like is to keep an array in
memory so that it doesn't have to be
reloaded each time a .php script is run.

Is this possible?

In Java, I could load the array from a file
in the init() method of a servlet and it would
stay in memory until the server is shutdown
or restarted, etc.

Fwrite And Memory Error
I'm trying to save an XML file sent to me in ZIP format.
Here is the code:
if($XMLFile=fopen($XMLPath.strtoupper(substr($file ,0,strlen($file)-4)).".XML",'w'))
if(fwrite($XMLFile,zip_entry_read($zip_entry,zip_e ntry_filesize($zip_entry)))){

here is the error:
Allowed memory size of 8388608 bytes exhausted (....)

The problem occurs on the "fwrite" function.

This appens when the XML file is very large (seems more than the 8mb limit).

I can't change this size server side, as my ISP doesn't allow me to do that.

Hot to fix the problem script side ?

Stack Memory Error
In 2 web hostings (hostinggratisargentina.com and
granjadeservidores.com), both using PHP 4.3 ( .9 and .10 respectively),
I get the strangest error:

Apparently, after using too much space in local variables, php just
uses the same memory space for the variables, assignment stops working,
and, well, everything fails.

function renderEcho() {

$x[0]=22;

if ($x[0]!=22) {echo 'DIFFERENT!' debug_zval_dump($x);} else
'EQUAL!!'

[...]
foreach (array_keys($this->childNodes) as $k) {
$this->childNodes[$k]->renderEcho();
}
}

Here's some output:

DIFFERENT!string(5) "2alue" refcount(3) DIFFERENT!string(5) "2alue"
refcount(3)
Warning: Cannot use a scalar value as an array in .../XMLNode.class.php
on line 100 (the assignment)
DIFFERENT!NULL refcount(1)

As you can see, sometimes it has a string, (which I think it should be
"value"), later it has NULL, and it never has an array.

I removed some temporary variables in someplaces and I got my script to
go further, but it still fails.

This problem does not exist in my ubuntu edgy PC (PHP 4.4.2-1.1).

PHP Memory For Multiple Websites
I would like to run multiple instances of TYPO3 (a cms written in PHP)
on a single server.

You can run multiple websites in two methods: multisite or multiple
instances.

In multiple instance, each instance uses the same source files but has
its own database and private file storage area.

In multisite, you can run multiple websites in a SINGLE T3 instance
because of its multisite feature. In this configuration there is only
on database and one php environment.

I would like to know if using multiple instances requires more php
memory than a single instance running multiple websites.

I was told that the bytecache (eaccelerator) is shared between all the
installations, and the PHP interpreter runs in global mode.

Therefore mod_php or fcgid believes it is running a single php instance
and does not know of the multipple instances.

So do I need more memory for one configuration vs the other?

PHP5: Memory Limits Not Available?
I've been googling all day and I haven't seen anyone else having this
problem, so I thought I'd check to see if I'm unique or I should be
expecting this behavior.

I've recompiled and reinstalled my PHP SO for Apache with the configure
flag "--enable-memory-limit" I'm running Apache 2.0.52 and PHP 5.0.3
(on FreeBSD 5.3). After restarting Apache with the new PHP SO in
place, I checked phpinfo(). The "configure line" does, in fact, show
"--enable-memory-limit" as one of the many configure options. However,
I've heard that there might also be a section or indication of memory
limit further down in the phpinfo() page. I don't see anything (the
only time the word "memory" shows up on the page is for the configure
line)--not even the php.ini settings are shown in the table.

I've checked the PHP 5.0.4 changelog and there is no indication that
they touched the memory limit code. There are currently no submitted
bugs regarding memory limits. I also haven't found any indication that
this function might not be available in the Apache module form of PHP.

The most important problem I'm having is that the memory_get_usage()
function is not available. I'm trying to write a small benchmarking
script to help generate statistics to compare scaling with large
amounts of database activity. I hope to prove that my technique is
faster and uses less memory than an existing piece of code. I've toyed
with the idea of reading the memory usage for the entire process using
ps, but that seems to scew things since, in addition to my script,
there's also a PHP interpreter with a bunch of overhead along with
whatever resources were necessary to open the shell and run

How Does One Trap For Out-of-memory Errors?
I'm not sure how this is normally done, on a large site, perhaps one
running Phorum. Occassionally a thread will have hundreds of entries,
perhaps a meg or two worth of data. You won't necessarily print all
that to the screen, but PHP has to hold it in memory. Run some
operations on it, or, more likely, have an array that you keep adding
things to, and very soon you run into the 8 meg limit that is the
default limit for PHP scripts.

How do you trap for out-of-memory errors? I want to do something like:

if (php is now using more than 8 megs) {
print "Sorry, but this operation requires more memory than PHP is
allowed.";
} else {
printOutEntryes($allEntries);
}

PHP has a command that checks the current memory usage of PHP, but
PHP, near as I know, has no command to estimate how much the next
operation is going to drive up memory usuage.

I'm sure this problem comes up for people using Phorum, or PostNuke,
or phpSlash, or phpMyAdmin or any of a lot of programs. How is it
normally handled?

Serious PHP Memory Management Problem
I have a PHP page that reads emails from an email account, parses them, processes the resulting information, and then sends out a response. I am in the process of testing it right now, and I am using a small sample (11 emails). I expect, when the site is fully functional, that I could be processing hundreds of emails at a time. I am running the site on a managed server that is dedicated, so I have a fair amount of memory.

Unfortunately, I get a fatal error:

Fatal error: Allowed memory size of 41943040 bytes exhausted (tried to allocate 6 bytes) in funcs_parse_emails.php on line 48

after only six emails. Clearly, if I am using up 42 megabytes, I have a serious problem.

Is there someone out there who can point me to a book or website that discusses PHP memory management issues or provides tools I can use? Alternatively, is there someone who has expertise in this area who would be willing to help me?

Parsing XML File Out Of Memory?
What I'm doing is the following:
- Load XML data a file
- Parsing the XML data
- Printing some parsed content

The problem is that the script execution is stopping before all the
content is parsed and printed.
Maybe the PHP is out of memory after a while. That would make sense
since the XML file is about 2 MB.

Shared Memory Confusion
I'm using the shmop_* functions to create and access shared memory. I've
never used shared memory before, so I apologize if my reasoning is
completely off...

$shm_id = shmop_open(ftok(__FILE__, 'a'), "c", 0600, 32);

That works for the first process, but if I try to launch a second process it
gives me the warning "Unable to create or attach shared memory" and fails.

According to the PHP manual, the 'c' flag will create shared memory, or if
one with the same key already exists, then it will open it for read/write
access - so I'm not sure why doesn't work (should it?). The manual page
mentions the last two args should be zero if I'm opening an existing memory
segment, but I don't know if I'm opening an existing segment when I execute
that line.

According to one of the manual comments, I can determine whether the memory
segment has been allocated already using the 'ac' flag:

1) $shm_id = shmop_open(ftok(__FILE__, 'a'), 'ac', 0, 0);
2) if(!$shm_id){
3) $shm_id = shmop_open(ftok(__FILE__, 'a'), 'c', 0600, 32);
4) }

But what happens if there is a context switch immediately after line 2 has
finished executing? Then two processes could both end up executing line 3,
and I'll get that warning again. Should I just use a semaphore to make
this atomic?

( linux 2.6, php 4.3.8)

How Can A GIF Image < 1KB Use Up 100+mb Of Memory With Imagecreatefromgif()?
re:
http://www.google.com/search?hl=en&...G=Google+Search

I am trying only this:

Code: ( php )

Imagecreatefrompng Memory Issue
I am having an odd issue with imagecreatefrompng since I upgraded to 5.2.3.  It is possible the issue below has nothing to do with it, but that is the major difference.

Using imagecreatefrompng on an image that is 1.5 MB, the max memory using is 143 MB.  On one that is 16 MB, it is 187 MB. Has anybody had anything similar happen with this? A few months ago, I ran a similar script on a 10MB image, and I did not exceed even 16MB. I would assume the memory should be much, much lower.

PHP Memory Garbage Collection
I have a script that uses a lot of memory and an ISP that has memory-limit
set to 10 Mb. The script of course doesn't finish running. :(

The program is rather simple - it parses XML into an array and then starts
the loop that inserts data into the database. If I use a very large XML
file then the PHP crashes inside the loop (Fatal error: Allowed memory size
of 10485760 bytes exhausted) - indicating that the problem lies within loop
somewhere.

Can I trace memory consumption of a PHP script so I can determine where the
memory is wasted?

If PHP uses all the memory (and frees nothing) until the end of the script
then that could be the problem - is there any way I can force it to do
garbage collection?

Any comment on how PHP uses memory would be appreciated - I would really
hate to have to break the script into smaller pieces (or change ISP for
that matter :) ).

Socket Memory Limit!?
I get this error when trying to download a file from a URL using a script form PHPatm.
Fatal error: Allowed memory size of 8388608 bytes exhausted (tried to allocate 67107842 bytes) in *index.php on line 1647 Code:

GD Functions Memory Error
Fatal error: Out of memory (allocated 73400320) (tried to allocate 4422 bytes) in /home/.marble/ryannaddy/beta.tzfiles.com/incl/db.php on line 111 Code:

Php With MySQL - Memory Problem
I wrote a little program to search all the tables in a particular database for a value. It was working just fine, but when I tried to search a very large database (73 large tables) it would return results for about 8 tables and then give an out of memory error. I tried using "mysql_free_result($result)"  (which I have commented out in the posted code), but that gave me an error saying "supplied argument is not a valid mysql result resource." Code:

Resize Script Uses Too Much Memory
I have this resize script: it works on smaller images but on larger images - over 2400 pixels wide, it uses too much memory Code:

Get PHP's Memory Limit
I tried: get_cfg_var('memory_limit'), but this only works sometimes..

Is there a clear way to get the current memory limit of PHP?

(I hate how badly GD handles memory limit problems)

Tracking Down Memory Consumption
I am running out of memory using a php script, but can't seem to determine what is eating the memory. I set the php ini to a ridiculous amount, but still get:

[Wed Mar 14 10:46:45 2007] [error] [client 192.168.69.100] PHP Fatal error:  Allowed memory size of 402653184 bytes exhausted (tried to allocate 2883495 bytes) in Unknown on line 0, referer: http://192.168.69.139/testing.php

I tried using the following function to determine the amount of memory usage:
function memory_log($str)
{
        debug_log("MEMORY " . round(memory_get_usage()/1024, 0) . "k - $str");
}

And make the call before and after, and during the function that APPEARS to be where the memory error occurs.  When I do so, it only reports using 30 MB of memory, not 300+.

Obviously running out on line zero hasn't helped a lot, and the function in question doesn't seem like it should be a big memory hog.  I am using php 5.2.0, and mysql 5.0.26.  What is the best way to diagnose an issue like this?

Saving Memory State
Is that possible to save memory state to a file? (i.e. the content of every variable)

How Much ~ Memory Does A Simple Array Eat?
say 500 items stored temporarily into an array variable with an id and title

$temp_array[$ID] = $title;
(title = varchar 150 character max)

it's for a page where it may,.. or may not be called... but when it is called, it could be called 1 or 10 times (it's a search page...) so I'm wondering if it's more sensible to load into memory temporarily for a split second rather than do up to 10 mysql queries for the title..

again, assume an array with 500 items~ is it no point worrying about the 4k or, what even less? maybe 1k?

Performance/memory With Arrays?
I am working on some financial calculators and although I succeeded to created the required formulas I am not sure about the following.To give an example: when somebody puts a capital on the bank with a yearly interest of x % , the final capital after, say, 30 years can easily be calculated. Since I want to be able to show the capital created after every year I prefer to do it with a loop, something like for($x= 1; $x < 30; $x++){ $capital = $capital*(1 + $interest /100) }.

Another reason for such a loop is that the visitor could tell that he want to withdraw some capital in the so-manieth year Now let's say the visitor of the page can do a "quick scan" (just showing the final amount) and request a table with all the yearly amounts afterwards. In this case I will either have to store all the yearly capital values into a an array and register that array to a session, or I will need to do the whole loop again but this time something like:

$capital = $capital*(1+ $interest/100);
echo "<tr><td>$capital</td></tr>";

Although the formulas I "translated" from several excel sheets work fine, I would like to know if storing such arrays could have negative consequences for performance or memory on the server Alternative suggestions, of course are also welcome. I tried to find similar scripts on Google but I wasn't very successfull, probably because I am not
very familiar with the English financial terms.

Semaphore And Shared Memory Functions
I was wondering if there was anyone out there that has used Semaphore and Shared Memory Functions? I wanted to tear apart phpChat and there are functions belonging to this class... My server admin is weary of security risks... Is there any risks of memeory leaks?

Allowed Memory Size Exhausted
i save images in a mysql db and i wrote a script called getimage.php to
display them.
in my getimage.php i want to resize my images to display them as
thumbnails but there always occurs the following error:

<b>Fatal error</b>: Allowed memory size of 188743680 bytes exhausted
(tried to allocate 240 bytes) in <b>.../public_html/getimage.php</b> on
line <b>x</b><br />

it always tries to allocate either 240 or 60 bytes.
line x equals: $image_p = imagecreatetruecolor($newWidth, $newHeight);

my configuration:


Copyright © 2005-08 www.BigResource.com, All rights reserved