Date: 11/17/00
- Next message: Johnson, Kirk: "RE: [phplib] more about "Fatal error: Unable to initialize a new token cache in session.inc " error"
- Previous message: Don Undeen: "[phplib] more about "Fatal error: Unable to initialize a new token cache in session.inc " error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Thanks SO much for your help.
Up to now, I didn't even know what a token cache was! I had thought it was
something from phplib, but now I see that it's from php itself, so I have to
dig a bit deeper for the fix.
I'm going to try to edit the TOKEN_BITS size, and see if that helps. If not, I
may have to mash some of the arrays into long strings (implode), and pull them
apart with explode later. But that seems like a clumsy hack, and since I'm
saving user-inputted data, it would be hard to find a safe separator
character.
One thing that troubles me is that I told feel like I was going nutty with the
number of registered session variables, though I did have some mulitdimensional
arrays.
But I never realized that the user and session classes were designed for
carrying around application data. That seemed to me the ideal way to carry
around that kind of information. Mostly what I'm doing is saving form data, so
I can reload pages with whatever the user entered last, and for saving lists of
IDs returned from searches, so that the user can traverse that list from the
pages where they edit each individual entry. Those are some useful things to
be able to do, and pretty straightforward to implement, were it not for this
arbitrary restriction in PHP3.
Thanks again for your help. I hope you don't mind my posting this reponse to
the list as a whole.
"Johnson, Kirk" wrote:
> Don,
>
> Find attached what little I've found on this error. You are on the right
> track- too many registerd variables. One of writers in the attached file is
> Zeev Zuraski, one of the PHP developers at Zend. There is a limit in PHP3 on
> the number of token caches that can be created. In my experience, if you
> have 1000 or more registered variables, you are at risk for this error. The
> quick cure is to reduce the number of persistent variables.
>
> Kristian has maintained that PHPLIB sessions were not designed to carry
> around application data, just session data. This is one of the reasons why.
>
> Good luck!
>
> Kirk
>
> -----Original Message-----
> From: Don Undeen [mailto:dundee <email protected>]
> Sent: Friday, November 17, 2000 12:28 PM
> To: phplib
> Subject: [phplib] more about "Fatal error: Unable to initialize a new
> token cache in session.inc " error
>
> For those that missed my last post:
> I'm getting this error when the sixe of my val column in the
> active_sessions array gets around 30K characters.
>
> ------------------------------------------------------------------------
> Name: token_cache.txt
> token_cache.txt Type: Plain Text (text/plain)
> Encoding: quoted-printable
Zeev's attached article:
It could be one of a few things.
First, you might be running out of memory (either your system really goes
out of memory, or you might have a limit imposed on your shell in some
way).
Another possibility to look at, especially if your application
repeatedly calls include() or eval() many times, is the following.
PHP 3.0 imposes an arbitrary limit on the number of token caches it can
create (usually 12 bit, or 4096 token caches). Each include() or eval()
statement generates a new token cache. Simple math will suggest you can
call include() and eval() upto 4095 times (combined), as the first token
cache is taken by the main file. On the 4096th include()/eval() - you'd
get that error.
Possible solutions for this problem are:
1. Waiting for PHP 4.0, which imposes no arbitrary limits of any kind.
2. Changing the constants in token_cache.h to accomodate for more token
caches. Edit token_cache.h, find where it defined TOKEN_BITS, and lower
the number to something lower than the default (which is 20). Every bit
you decrease here, doubles the amount of token caches you can generate
(e.g., if you reduce it to 18, you can generate upto 16384 token caches
instead of 4096).
You may wonder why not to simply reduce that number to a zero and get a
whopping 4,294,967,296 number of token caches. The explanation is simple.
The lower TOKEN_BITS is, the smaller each token cache can be, which limits
the size of code you may have in each file in your PHP application. You'd
simply have to conduct a few trials to see how well stuff works for you
(reducing it to 19 or 18 should be safe, programs that require token
caches that big are very rare).
After your change that constant in token_cache.h, be sure to recompile PHP
and possibly relink it with Apache (if you use an Apache module).
Again, very soon you won't have to worry about it any longer.
Zeev
---------------------------------------------------------------------
To unsubscribe, e-mail: phplib-unsubscribe <email protected>
For additional commands, e-mail: phplib-help <email protected>
- Next message: Johnson, Kirk: "RE: [phplib] more about "Fatal error: Unable to initialize a new token cache in session.inc " error"
- Previous message: Don Undeen: "[phplib] more about "Fatal error: Unable to initialize a new token cache in session.inc " error"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

