Modify PHP code to better use MySQL so that PHP consumes less memory

CANCELLED
Bids
6
Avg Bid (USD)
$75
Project Budget (USD)
$30 - $250

Project Description:
I have written a custom module for SugarCRM. The module works great when there is minimal data being computed from the database. Over the last 6 months our database has grown. And now my module uses too much memory and I'm getting the following error from several parts of the module:

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 87 bytes) in /home/millpond/public_html/crm_live/data/SugarBean.php on line 638

I can no longer simply allocate more memory to the program. So I need someone to go through the module and optimize it to do less PHP calculations and rather do more MySQL calculations. Furthermore, I think that SugarCRM is not letting some of my objects be collected by the PHP garbage collection. So with each iteration, my memory requirements grows.

Understand that although you don't need to know SugarCRM to do this work it will likely be helpful. When you bid this please tell me how well you know SugarCRM.

There are four many functions that will have to be looked at. Each function is generally spread out over several several files.

Charge Monthly Late Fee
Charge Monthly Rent
Update Address & Phone
Update Company & Balance

I've attached a file that contains all of the custom code that may need to be reviewed. The pdf folder does not contain custom code. If you work on this project, you will get the full working module which contains a lot of additional code that is part of SugarCRM.

Below is example of one of the charge rent function. You can see that much of this code could be executed within my MySQL database. Furthermore, I want to make sure that with each iteration of an account we are freeing the memory of the previous account.

<?php

function ChargeRent(){
$GLOBALS['log']->debug('Starting the ChargeRent() function.');
$account = new Account();
$accounts = $account->get_full_list();

foreach($accounts as $account) {
$units = $account->get_linked_beans('msk_unit_accounts', 'msk_unit');
foreach($units as $unit) {
$rentLevel = $unit->get_linked_beans('msk_rentlvl_msk_unit', 'msk_rentlvl');
$rent = new msk_Rent();
$rent->name = strftime("%B's Rent for $unit->name");
$rent->amount = $rentLevel[0]->monthly_rent * -1;
$rent->type = 'Rent';
$rent->save();

$rent->load_relationship('msk_rent_accounts');
$rent->msk_rent_accounts->add($account->id);
}
if($account->monthly_rent_adjustment_c != 0) {
$rent = new msk_Rent();
$rent->name = strftime("%B's Rent Adjustment");
$rent->amount = $account->monthly_rent_adjustment_c * -1;
$rent->type = 'Adjustment';
$rent->save();

$rent->load_relationship('msk_rent_accounts');
$rent->msk_rent_accounts->add($account->id);
}
}

$GLOBALS['log']->debug('ChargeRent() function is complete.');
return true;
}

?>

Skills required:
MySQL, PHP
Additional Files: Rental.zip
Hire mikleing
Project posted by:
mikleing United States
Verified
Public Clarification Board
Bids are hidden by the project creator. Log in as the project creator or as one of the bidders to view bids.
You will not be able to bid on this project if you are not qualified in one of the job categories. To see your qualifications click here.