PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Autres forums > Forum Programmation & Conception > comp.lang.php > Allowed memory size of 16777216 bytes exhausted
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
Allowed memory size of 16777216 bytes exhausted

Réponse
 
LinkBack Outils de la discussion
Vieux 12/09/2007, 16h57   #1
Jim Carlock
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Allowed memory size of 16777216 bytes exhausted

I'm filling a really large array. Is there a way to get by
this error message without editing the php.ini? The array
needs to get built once, then looped through to fill a data-
base, and it will get alot bigger than 1.5MB, I'm going to
guess maybe at least 100MB.

<snip>

[12-Sep-2007 11:41:53] PHP Fatal error: Allowed memory size
of 16777216 bytes exhausted (tried to allocate 10 bytes) in...
.... on line 23687

</snip>

The other thing I was thinking of involves using a function
that gets supplied an index and returns only 20 or 50 items
at a time.

Thanks for any comments/suggestions.

--
Jim Carlock
Swimming Pool, Spa And Water Feature Builders
http://www.aquaticcreationsnc.com/


  Réponse avec citation
Vieux 12/09/2007, 17h04   #2
Rik Wasmus
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Allowed memory size of 16777216 bytes exhausted

On Wed, 12 Sep 2007 17:57:57 +0200, Jim Carlock <anonymous@127.0.0.1>
wrote:

> I'm filling a really large array. Is there a way to get by
> this error message without editing the php.ini? The array
> needs to get built once, then looped through to fill a data-
> base, and it will get alot bigger than 1.5MB, I'm going to
> guess maybe at least 100MB.
>
> <snip>
>
> [12-Sep-2007 11:41:53] PHP Fatal error: Allowed memory size
> of 16777216 bytes exhausted (tried to allocate 10 bytes) in...
> ... on line 23687
>
> </snip>


http://www.php.net/manual/en/ini.cor...i.memory-limit

So, normally this would be perfectly changable in the script itself, in a
..htaccess or httpd.conf (for Apache), etc.

> The other thing I was thinking of involves using a function
> that gets supplied an index and returns only 20 or 50 items
> at a time.


I'd look into possible solutions not even building your array, but a
straight insert (or update!) into the database. It depends on the actual
code/purpose though.

--
Rik Wasmus
  Réponse avec citation
Vieux 12/09/2007, 19h50   #3
Jim Carlock
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Allowed memory size of 16777216 bytes exhausted

"Rik Wasmus" wrote...
: http://www.php.net/manual/en/ini.cor...i.memory-limit

: So, normally this would be perfectly changable in the script itself,
: in a .htaccess or httpd.conf (for Apache), etc.

Thanks, Rik.

It took me a little while to find the appropriate function to set
the value. So to others out, here's the function name and
use to others reading along.

ini_set("memory_limit", "256M");

--
Jim Carlock
Swimming Pool, Spa And Water Feature Builders
http://www.aquaticcreationsnc.com/


  Réponse avec citation
Vieux 12/09/2007, 20h07   #4
Good Man
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Allowed memory size of 16777216 bytes exhausted

"Jim Carlock" <anonymous@127.0.0.1> wrote in news:46e834e6$0$11048
$4c368faf@roadrunner.com:

> "Rik Wasmus" wrote...
>: http://www.php.net/manual/en/ini.cor...i.memory-limit
>
>: So, normally this would be perfectly changable in the script itself,
>: in a .htaccess or httpd.conf (for Apache), etc.
>
> Thanks, Rik.
>
> It took me a little while to find the appropriate function to set
> the value. So to others out, here's the function name and
> use to others reading along.
>
> ini_set("memory_limit", "256M");
>


Interesting to see 'memory_limit' as a changeable setting via ini_set();

So, if a webhost set the PHP memory limit to 24M, and I know they have 2GB
on the machine, is it being suggested that I can override the limit set in
php.ini with a simple ini_set directive? This seems to put quite a lot of
'power' into the hands of PHP scripters?

  Réponse avec citation
Vieux 12/09/2007, 21h24   #5
Anonymous
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Allowed memory size of 16777216 bytes exhausted

Good Man wrote:
> > It took me a little while to find the appropriate function to set
> > the value. So to others out, here's the function name and
> > use to others reading along.
> >
> > ini_set("memory_limit", "256M");
> >

>
> Interesting to see 'memory_limit' as a changeable setting via ini_set();
>
> So, if a webhost set the PHP memory limit to 24M, and I know they have 2GB
> on the machine, is it being suggested that I can override the limit set in
> php.ini with a simple ini_set directive? This seems to put quite a lot of
> 'power' into the hands of PHP scripters?


Of course it is possible to prevent the value from being changed. If
settings were set with php_admin_value or php_admin_flag they can not be
changed.

And any descent host should know this.

Bye!
  Réponse avec citation
Vieux 13/09/2007, 00h56   #6
Jeff Johns
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Allowed memory size of 16777216 bytes exhausted

Do you need to build the array? Are you building this array from a
file? If so why not format the file and do a LOAD FILE query or better
yet use PhpMyAdmin to upload your file. Not sure if you need to make
the array then upload from the array.

Any possibility we can see some of your code?

  Réponse avec citation
Vieux 13/09/2007, 05h20   #7
Jim Carlock
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Allowed memory size of 16777216 bytes exhausted

"Jeff Johns" wrote...
: Do you need to build the array? Are you building this array
: from a file? If so why not format the file and do a LOAD FILE
: query or better yet use PhpMyAdmin to upload your file. Not
: sure if you need to make the array then upload from the array.
:
: Any possibility we can see some of your code?

Well, it's easy to convert to a .csv format, but I don't mess
with PhpMyAdmin. I took a look at that once a while back but I
end up seeing too many hacks against it, which creates a rather
insecure feeling.

The array is easy enough to convert to a regular CSV file and
other database formats from that. No I don't need to build the
array. That's just the way it started out.

Thanks for asking. I won't have any code to show for awhile.
I'm just creating an array which will create a database. I
suppose I can get to know the file (line) reading functions of
PHP as another way to get this done, but that's not my interest
right at the moment. I'm playing around with big arrays.

I'm curious to others suggestions. I think I'll end up using
SQLite IF I get done with this.

// over 6000 API definitions...

// index, Win32APIFunctionName, ParameterList, ParameterListDesc, ReturnValue, ReturnValueDescSuccess, ReturnValueDescFailure,
Purpose_URI, Purpose_desc

return(array(
array(0, "AbortDoc", "(hdcWORD)", "plist_desc", "eSuccessWORD", "32-bit", "Upon success, the return value is greater than zero
(0).", "Upon failure, the return value is SP_ERROR.", "http://msdn2.microsoft.com/en-us/library/ms535758.aspx", "<p>AbortDoc() stops
the current print job and erases everything drawn since the last call to StartDoc().</p>\n<p><b>Windows NT/2000/XP:</b> Call
GetLastError() for extra error information.</p>"),


--
Jim Carlock
Swimming Pool, Spa And Water Feature Builders
http://www.aquaticcreationsnc.com/


  Réponse avec citation
Vieux 13/09/2007, 12h33   #8
Jerry Stuckle
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Allowed memory size of 16777216 bytes exhausted

Jim Carlock wrote:
> "Jeff Johns" wrote...
> : Do you need to build the array? Are you building this array
> : from a file? If so why not format the file and do a LOAD FILE
> : query or better yet use PhpMyAdmin to upload your file. Not
> : sure if you need to make the array then upload from the array.
> :
> : Any possibility we can see some of your code?
>
> Well, it's easy to convert to a .csv format, but I don't mess
> with PhpMyAdmin. I took a look at that once a while back but I
> end up seeing too many hacks against it, which creates a rather
> insecure feeling.
>


I have PHPMyAdmin on several sites and never have a problem. They're
just in password protected directories so no one can get to them.

As for the hacks - just keep it updated, like everything else.

Or, you can continue to make things difficult for yourself. Your choice.

Or, are you confusing PHPMyAdmin (a web-based tool) with MySQL (a
database)? Again, I've had zero problems with MySQL on the systems I
have. But I have security in place, also.

> The array is easy enough to convert to a regular CSV file and
> other database formats from that. No I don't need to build the
> array. That's just the way it started out.
>
> Thanks for asking. I won't have any code to show for awhile.
> I'm just creating an array which will create a database. I
> suppose I can get to know the file (line) reading functions of
> PHP as another way to get this done, but that's not my interest
> right at the moment. I'm playing around with big arrays.
>


Generally a sign of a poor implementation. Use a database.

> I'm curious to others suggestions. I think I'll end up using
> SQLite IF I get done with this.
>


I'd highly recommend MySQL or PostgreSQL over SQLite. Much more robust.


> // over 6000 API definitions...
>
> // index, Win32APIFunctionName, ParameterList, ParameterListDesc, ReturnValue, ReturnValueDescSuccess, ReturnValueDescFailure,
> Purpose_URI, Purpose_desc
>
> return(array(
> array(0, "AbortDoc", "(hdcWORD)", "plist_desc", "eSuccessWORD", "32-bit", "Upon success, the return value is greater than zero
> (0).", "Upon failure, the return value is SP_ERROR.", "http://msdn2.microsoft.com/en-us/library/ms535758.aspx", "<p>AbortDoc() stops
> the current print job and erases everything drawn since the last call to StartDoc().</p>\n<p><b>Windows NT/2000/XP:</b> Call
> GetLastError() for extra error information.</p>"),
>
>


You definitely need a database.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 12h41.


Édité par : vBulletin® version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,17610 seconds with 16 queries