Reputation: 228
i need a structure like this
array(){
[0] => array(){
[0] => array(){
// this array will have 'n' values(n is large, like 2000)
}
[1] => array(){
// this array will have 'n' values(n is large, like 2000)
}
}
.
.
.
[n] => ............
}
n arrays will each have a 2 element array, where each element has an array of n values.
I used $list[$m][0][$n]
and $list[$m][1][$n]
inside 2 for loops where $m,$n
vary from 0...2000
this crosses the allowed memory size.. i can change the size in php.ini, but i want to optimize my memory usage and not change the limit.
will using objects help ?
Please provide some sample code to understand. Thank you.
Upvotes: 0
Views: 1318
Reputation: 401182
Using objects will most likely not help (it might even be worse).
What you need to do, in a case such as this one, is re-think :
Upvotes: 5
Reputation: 449803
Assuming that the net weight of your data crosses the memory limit, I can't see how objects could be of help. For the purposes of data storage, they're just a different form of notation, really. Maybe one method will save a byte per piece over the other - I don't know, but if there's a difference, my bet is objects are more expensive.
But I think the general question is what you are trying to do with that lot of data? Could it be feasible to store parts of it to disk or the database, and have only a part of it in memory?
Upvotes: 3