473,396 Members | 1,846 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

unsetting or destroying objects necessary?

Hi,

I'm building an application with over 10thousand database entries. I
was wondering if it would be useful, regarding memory load and server
performance to unset/destroy objects at the moment when they are no
longer needed.
Will this improve performance, or will it not make any difference.

Thanks for any help.

TooN
Jul 17 '05 #1
6 12701
"TooN" <to**@company.com> wrote in message
news:181220031346399251%to**@company.com...
Hi,

I'm building an application with over 10thousand database entries. I
was wondering if it would be useful, regarding memory load and server
performance to unset/destroy objects at the moment when they are no
longer needed.
Will this improve performance, or will it not make any difference.

Thanks for any help.

TooN

Won't make a great deal of differnece how may entries you have. Unsetting
variables requires processor power, so if anything, it may even make your
scripts slower.
IMHO I wouldn't bother.

Regards
Richard Grove

http://shopbuilder.org - ecommerce systems
Become a Shop Builder re-seller:
http://www.affiliatewindow.com/affil...ls.php?mid=611
http://www.affiliatewindow.com/a.pl?590

Jul 17 '05 #2
TooN wrote:
I'm building an application with over 10thousand database entries. I
was wondering if it would be useful, regarding memory load and server
performance to unset/destroy objects at the moment when they are no
longer needed.
Will this improve performance, or will it not make any difference.


As another poster said, it probably won't make a big difference;
however, suppose you grab 50K (too farfetched?) from the database and
have 200 simultaneous users -- that makes 10M of data loaded into RAM
while each script is executing ... maybe you'd like to limit that only
to the parts of the script where it is needed only. Anyway they'll be
unset when you tell PHP to (with unset()) or at the end of the script.

I tend to do it for "large" things

<?php
// ...
$res = mysql_query($sql)
// deal with it
unset($res);
// ...
?>

<?php
// ...
$data = file('http://www.example.com/large_page.html');
// extract data
unset($data);
// ...
?>
--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #3
In article <3f***********************@mercury.nildram.net>, Richard
Grove wrote:
"TooN" <to**@company.com> wrote in message
news:181220031346399251%to**@company.com...
Hi,

I'm building an application with over 10thousand database entries. I
was wondering if it would be useful, regarding memory load and server
performance to unset/destroy objects at the moment when they are no
longer needed.
Will this improve performance, or will it not make any difference.

Thanks for any help.

TooN

Won't make a great deal of differnece how may entries you have. Unsetting
variables requires processor power, so if anything, it may even make your
scripts slower.
IMHO I wouldn't bother.

Regards
Richard Grove


Just what I thought.
Thanks for answering!

TooN
Jul 17 '05 #4
I (Pedro Graca) wrote:
<?php
// ...
$res = mysql_query($sql)
// deal with it
unset($res);
oops ... that should have been
mysql_free_result($res); // ...
?>

--
--= my mail box only accepts =--
--= Content-Type: text/plain =--
--= Size below 10001 bytes =--
Jul 17 '05 #5
In article <br************@ID-203069.news.uni-berlin.de>, Pedro Graca
<he****@hotpop.com> wrote:

Thanks for thinking along with me,
although I don't expect 200 simultaneous users, we keep it in mind!

Toon

As another poster said, it probably won't make a big difference;
however, suppose you grab 50K (too farfetched?) from the database and
have 200 simultaneous users -- that makes 10M of data loaded into RAM
while each script is executing ... maybe you'd like to limit that only
to the parts of the script where it is needed only. Anyway they'll be
unset when you tell PHP to (with unset()) or at the end of the script.

I tend to do it for "large" things

<?php
// ...
$res = mysql_query($sql)
// deal with it
unset($res);
// ...
?>

<?php
// ...
$data = file('http://www.example.com/large_page.html');
// extract data
unset($data);
// ...
?>

Jul 17 '05 #6
TooN <to**@company.com> wrote in message
news:<181220031346399251%to**@company.com>...

I'm building an application with over 10thousand database entries. I
was wondering if it would be useful, regarding memory load and server
performance to unset/destroy objects at the moment when they are no
longer needed.
Will this improve performance, or will it not make any difference.


Surprise, surprise... Using unset() on an object DOES NOT free up
any memory in PHP 4. Zurab Davitiani posted his observations on the
subject to this newsgroup back in October:

http://groups.google.com/groups?hl=e...ws.prodigy.com

This is expected to be resolved in PHP 5, which implements
destructors.
Until then, your best bet for a high-performance memory-intensive
application is to ban OOP from it (which, in my book, is always a good
idea to consider when working with PHP. PHP does not run on a virtual
machine and has no system objects; all calls to OS and other low-level
software such as database engines are procedural, so there is no need
to introduce the overhead of OOP, unless you are into refactoring, in
which case you are simply buying shorter application development time
with lower application performance).

Cheers,
NC
Jul 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

49
by: Steven Bethard | last post by:
I promised I'd put together a PEP for a 'generic object' data type for Python 2.5 that allows one to replace __getitem__ style access with dotted-attribute style access (without declaring another...
4
by: pachanga | last post by:
After you destroy a Object and its send to the garbage collections, can you retrieve the object back? Also, if you can, can you destroy an object permantly with no trace of it?
2
by: jaymtz78 | last post by:
Hi, I have a huge windows application that I'm working on and I'm completely baffled. Sometimes when I try to close the application, it won't let me! I have an Exit button in my menu bar that...
3
by: Microsoft | last post by:
I am working on a VB.NET (2003) application and I am confused about object lifetimes. I have a class of objects that are created in a manager class and added to a collection in that class. I am not...
1
by: tilbyj | last post by:
Hello, I am new to .NET, and am trying to write an application that connects to a DCOM server that we use. Wonderfully (unlike with ASP) I can now import the type library for my DCOM server, and...
17
by: Shelly | last post by:
I have the following for a test of the submit button being pressed: if (isset($_POST)) { This works fine and I have been doing this for a long time. Here is the question: If I do a submit...
4
by: Olumide | last post by:
Hello - I have two classes A and B as follows: class B{ public: ~B(){ cout << "destroying B" << endl; } }; class A{
3
by: Bartholomew Simpson | last post by:
I am writing some C++ wrappers around some legacy C ones - more specifically, I am providing ctors, dtors and assignment operators for the C structs. I have a ton of existing C code that uses...
41
by: =?Utf-8?B?VGltIE1hcnNkZW4=?= | last post by:
Hi, I am after suggestions on the best practice declaring and destroying objects. some example code: Private Sub MySub Dim frmMyForm As MyForm Try
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.