Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7953225
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T03:05:54+00:00 2026-06-04T03:05:54+00:00

I am creating an array to hold values returned from a query – It

  • 0

I am creating an array to hold values returned from a query – It seems adding to a multi dimensional array causes the script to take upto 125Mb of memory and considering the total amount of data that the array is supposed to hold is not more than 5Mb it’s very weird:

Here is what I am doing:

try 
{
    if (!$link = mysql_connect(DB_Host, DB_User, DB_Password))
            Throw New Exception(mysql_error());
    if (!mysql_select_db("Spexplus_Demo"))
            throw New Exception(mysql_error());
} 
catch (Exception $e) 
{
    echo $e->getMessage().$e->getTraceAsString();
    exit(1);
}

$query = "select cda.categoryid as categoryId, 
                  cda.templatetype as templateType, 
                  hn.headerid as headerId, 
                  hn.name as headerName, 
                  an.attributeid as attributeId, 
                  an.name as attributeName
                  from categorydisplayattributes cda 
                  join categoryheader ch on cda.headerid = ch.headerid 
                  and cda.templatetype = ch.templatetype 
                  and cda.categoryid = ch.categoryid 
                  join headernames hn on cda.headerid = hn.headerid 
                  and hn.localeid = 1
                  join attributenames an on cda.attributeid = an.attributeid 
                  and an.localeid = 1";

$result = mysql_query($query);

while($row = mysql_fetch_assoc($result))

        {
            $categorydisplayattributes[$row['categoryId']][$row['templateType']][$row['headerId']][$row['headerName']][$row['attributeId']][$row['attributeName']] =array() ;
        }


echo "Memory After CDA:".memory_get_usage(TRUE).Line_Terminator;
exit();

The query result itself doesn’t go beyond 5Mb or so when I check, however, assigning the values to the array in this fashion causes the spike – Has anyone else encountered something like this?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T03:05:56+00:00Added an answer on June 4, 2026 at 3:05 am
        while($row = mysql_fetch_assoc($result))
    
    
               {
    
    //concatenate the values using '.' if string 
    
    $index = $row['categoryId']][$row['templateType']][$row['headerId']][$row['headerName']][$row['attributeId']][$row['attributeName'];
    
                    $categorydisplayattributes[$index] =array() ;
                }
    

    try that.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm creating an array that needs to hold some empty values like this: $my_array['message']
I'm creating an array of view controllers, adding them to a UINavigation Controller, and
What is the prefered method for creating a byte array from an input stream?
i need help with creating a regex for putting all values into an array!
I am creating an array of double values,I want to add the created array
I am creating an array of string objects in PowerShell which needs to be
So I'm creating an array called fruits which I would like to share between
Why is it that for user defined types when creating an array of objects
what i want to do is that i am creating php array dynamic .i
When creating a 3D array in C#, which is a better way to create

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.