Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > PHP/MySQL > PHP Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
PHP Databases Using PHP in conjunction with databases. PHP questions not specific to databases should be directed to one of the other PHP forums.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the PHP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old June 20th, 2006, 03:18 AM
Authorized User
 
Join Date: Jun 2006
Location: bombay, maharashtra, India.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default Allowed memory size of 33554432 bytes exhausted

my php program is quering database brings data after
querying and processes it ..my database is postgresql and data which it
brings is more in number so i used query instead of getAll functiion of pear
can somebosy please guide me what can be the reason behind it ???
Thanks a lot
Nidhi Mittal

nidhi
__________________
nidhi
Reply With Quote
  #2 (permalink)  
Old June 20th, 2006, 09:47 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Use functions such as pg_free_result() to free up memory after processing a query.

http://www.php.net/pg_free_result

I'm not familiar with PEAR's database wrappers, but I'm sure there's something like that in there.

Otherwise, increase PHP's memory limit in php.ini.

Regards,
Rich

--
Author,
Beginning CSS: Cascading Style Sheets For Web Design
CSS Instant Results

http://www.catb.org/~esr/faqs/smart-questions.html
Reply With Quote
  #3 (permalink)  
Old June 21st, 2006, 12:19 AM
Authorized User
 
Join Date: Jun 2006
Location: bombay, maharashtra, India.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks a lott sir
i tried to increase the memory limit in php.ini from 32 MB to 64 MB
it is still giving the same message my total RAM is 256 MB
somebody suggetsed me to put -1 in php.ini Memory Limit
i did it rather i put
Memory Limit =1024 MB
it worked okay ...
but i feel it was a wrong solution ..

and let me try your first solution thanks a lott
nidhi mittal
India

nidhi
Reply With Quote
  #4 (permalink)  
Old June 22nd, 2006, 05:03 AM
Authorized User
 
Join Date: Jun 2006
Location: bombay, maharashtra, India.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi sir
i tried $res->free(); dat's a function of pear for the same purpose
but same error is coming ..
please guide me some other solution i really need it

nidhi
Reply With Quote
  #5 (permalink)  
Old June 22nd, 2006, 07:25 AM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

Now would be a good time to post some code so we can see what's going on. Just the relevant snips will do.

Regards,
Rich

--
Author,
Beginning CSS: Cascading Style Sheets For Web Design
CSS Instant Results

http://www.catb.org/~esr/faqs/smart-questions.html
Reply With Quote
  #6 (permalink)  
Old June 23rd, 2006, 02:52 AM
Authorized User
 
Join Date: Jun 2006
Location: bombay, maharashtra, India.
Posts: 18
Thanks: 0
Thanked 0 Times in 0 Posts
Default

 do
  {
     $empno=$row['empno'];
    //echo"<BR> empno obtained is $empno";
    $information='';
    foreach($row_key_array as $key)
   {
    $field_name=$key;
    $field_id = $field_id_arr[$field_name];
    $information= $row[$field_name];
    $keyword_arr=array();
    $keyword_arr=$searchengine->separate_keywords($information);
    foreach($keyword_arr as $keyword)
    {
      $keyword=$searchengine->keyword_processing($keyword);
    if($keyword!='NO-KEYWORD' and $keyword!='IRRELEVENT')
   {
      $keyword=addslashes($keyword);
      $keyword_id=$searchengine->addkeyword($keyword);
      $add_emp_result=$searchengine->addempno($keyword_id,$empno,$table_id,$field_id );
   }
  }//for each keyword_arr
  }//for each row_key_array

 }while($main_result->fetchInto($row,DB_FETCHMODE_ASSOC));

DESCRIPTION:


for every employee number this while loop works and there are two functions shown in the code addkeyword(----) and addempno(----)
both functions add something to the databse tables
that means both contains "insert" statements
no doubt there are hundreds of employees and for each employee there are many keywords and for each of those keywords these two functions are called ...

if you wish to see now i will paste these two functions code also

but i feel there is some memory exhaustion problem like somewhere
script is occupying the whole memory without freeing earlier occupied one....
please see and reply...
and one more thing can you please reply in day time as i get your reply after 24 hrs ...
Thanks
nidhi

nidhi
Reply With Quote
  #7 (permalink)  
Old June 23rd, 2006, 10:37 PM
richard.york's Avatar
Wrox Author
Points: 5,506, Level: 31
Points: 5,506, Level: 31 Points: 5,506, Level: 31 Points: 5,506, Level: 31
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Camby, IN, USA.
Posts: 1,706
Thanks: 0
Thanked 6 Times in 6 Posts
Default

I still don't have enough information to form any recommendations, it seems. I'd have to see what's going on in these methods that are being called.

Why do you need to split keywords? Is this some effort to recreate a fulltext index? I don't know much about pgsql, but if I were you I'd look into built-in tools for database optimization. Typically this will involve creating indexes on your database tables, which facilitate more efficient retrieval of data.

http://www.devx.com/opensource/Artic...4/1954?pf=true

Some time with Google ought to help you with this one.

You can form some stats for yourself, time the execution of each function to narrow it down. You can do that with a microtime function.

Code:
function microtime_float()
{
    list($usec, $sec) = explode(' ', microtime());
    return ((float)$usec + (float)$sec);
}
Then to do a benchmark, place the following where you want to begin the benchmark...
Code:
$time_start = microtime_float();
...and the following where you want to end the benchmark...
Code:
echo round((microtime_float() - $time_start), 2);
This will give you the time of execution in seconds. If you have anything over a second, your program is taking entirely too long to execute. You can use a technique like this to narrow down the bottleneck to a particular snippet of code. Most web-based applications do their business in a fraction of a second, and if you're spending that much memory, I'd venture to say that time is also an issue.

It really sounds like you need fulltext indexing on your database tables which would eliminate the need for spliting up keywords and that sort of thing, but I'm just speculating, as again, I'd need to see what those functions are doing to know for sure.

The other thing you can do is implement garbage collection. After everything you do in your script, be sure to clean up after yourself. unset() variables after you're finished with them. Close connections to outside services. Free result sets after you're done with a query (as mentioned in my previous post).

Regards,
Rich

--
Author,
Beginning CSS: Cascading Style Sheets For Web Design
CSS Instant Results

http://www.catb.org/~esr/faqs/smart-questions.html
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Getting a set number of bytes from a file toddw607 VB How-To 3 August 15th, 2007 02:22 PM
convert 4 bytes to bit array Vinny_68 Pro Visual Basic 2005 1 March 21st, 2007 05:40 PM
convert bytes[] into base64binary in asp.net bharat_agarwal XSLT 1 June 20th, 2006 02:04 AM
DUPLICATES NOT ALLOWED codedriller General .NET 9 July 27th, 2004 03:05 PM
Bytes doa-wnloaded vincentvdm Classic ASP Professional 0 August 17th, 2003 01:52 PM



All times are GMT -4. The time now is 07:59 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.