473,406 Members | 2,220 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,406 software developers and data experts.

Life time of a Initialized object

When I create a "new object that is included in a page how long does that object remain in memory?

I can find no destroy object in the docs. In Delphi we would develop a bitchin memory leak if we didn't "dispose" of objects

Len
Jun 27 '08 #1
6 3543
lenbell schreef:
When I create a "new object that is included in a page how long does
that object remain in memory?
Hi,

Simple: end of script.
When a PHP scripts ends, it destroys everything you created in it.
That includes objects you created and database connections, etc.
>
I can find no destroy object in the docs. In Delphi we would develop a
bitchin memory leak if we didn't "dispose" of objects
As far as I know PHP always behaves nicely when it comes to freeing
memory it used.
(At least on *nix/apache I use a lot. I had some problems with PHP5 on
IIS7 though, a dreaded 'worker thread stopped responding' popup that
seems to backtrack to PHP freeing the same memoryblocks twice. Not my
area of expertise, so I am only echo'ing what I read.)

>
Len
Regards,
Erwin Moller
Jun 27 '08 #2
lenbell wrote:
When I create a "new object that is included in a page how long does
that object remain in memory?

I can find no destroy object in the docs. In Delphi we would develop a
bitchin memory leak if we didn't "dispose" of objects

Len
Depending on where you instantiate a class, an object can remain in the
memory for the duration of the request,
or when invoking from command line, as long as the script remains running.

You should check this out:
http://au.php.net/manual/en/language...bles.scope.php
Jun 27 '08 #3
Ok - I think I get it

Just to be sure

I have a php page - I guess you call them "headers" that has at the top of it an include in that include is a class and after the class i initialize the class. Can I believe that when that "header is no longer active (user went to another page) the class will be destroyed?

For all yea purists I topped this page because I was the original author.
"lenbell" <ls****@charter.netwrote in message news:Bt************@newsfe02.lga...
When I create a "new object that is included in a page how long does that object remain in memory?

I can find no destroy object in the docs. In Delphi we would develop a bitchin memory leak if we didn't "dispose" of objects

Len
Jun 27 '08 #4
lenbell wrote:
When I create a "new object that is included in a page how long does
that object remain in memory?

I can find no destroy object in the docs. In Delphi we would develop a
bitchin memory leak if we didn't "dispose" of objects

Len
The easiest way to destroy an object is to remove all references to it, i.e.

$myobj = new MyObject(); // Creates an object
....
$myobj = null; // or any other non-object, i.e. 1.

Once all references are removed, the PHP garbage collector will
eventually get around to releasing the memory. It may not be
immediately, but whenever the gc gets a chance to run.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Jun 27 '08 #5
..oO(lenbell)
>Ok - I think I get it

Just to be sure

I have a php page - I guess you call them "headers" that has at the top
of it an include in that include is a class and after the class i
initialize the class. Can I believe that when that "header is no longer
active (user went to another page) the class will be destroyed?
As soon as a HTTP request is answered, all used resources are auto-
matically freed by default. A new page is a new HTTP request, which
means that a new script (or a new instance of the same script) is
invoked, completely independent from the previous one.

Two other things:

Please don't top-post and please don't send HTML postings, plain text is
preferred in almost every newsgroup.

Micha
Jun 27 '08 #6
..oO(lenbell)
>God forbid I top post and holly cow I think he post html. Will the saints
forgive me. Why O why does my email sender machine goes to the top. Could
it be that that is the way it should be done?
No. This is not email, this is usenet.
>[lots of stupid insults snipped]
This is not the first time you're insulting people who have spent their
time to help you for free. You already have been warned to think about
your attitude and calm down. And no, your dyslexia is not an excuse for
the lack of social competence.
>X-Complaints-To: ab***@charter.net
Next time, I promise.

*plonk*

Micha
Jun 27 '08 #7

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

Similar topics

4
by: Steven T. Hatton | last post by:
I mistakenly set this to the comp.std.c++ a few days back. I don't believe it passed the moderator's veto - and I did not expect or desire anything different. But the question remains: ISO/IEC...
4
by: user | last post by:
Hi, I am using a matrix library in this way: MyClass::myFunc() { Matrix *p = CreateMatrix( ... ); ... }
1
by: Johan Lindh | last post by:
This is somewhat obscure, and I'm not sure if the question is valid in comp.lang.c. If it isn't, please ignore it. In a C program, the pointer resulting from a __FILE__ is stored. The pointer...
6
by: jim | last post by:
Hi All, I like to know the life cycle of an ASP .NET Application( incudieng server application, such as .NET Web Service). That means from initialization to fully running and how to reboot it or...
5
by: Peter Rilling | last post by:
I have an interesting issues that, although I not blocking me, is not very performance. Maybe someone can suggest a better way of doing this. 1) I have a page that displays a grid with command...
10
by: ElanKathir .S.N | last post by:
Hi all ! VB.NET adds the ability to create variables that are visible only within a block. A block is any section of code that ends with one of the words End , Loop , or Next . This means that...
3
by: bb | last post by:
Hi, Have a query regarding the life of temporaries. Here is the code... class MyNumber { public: MyNumber(int n) : n(n) { cout << "Object Constructed." << endl; }
2
by: =?utf-8?B?5Lq66KiA6JC95pel5piv5aSp5rav77yM5pyb5p6B | last post by:
Please see the followed example: class A: def __init__(self): pass class X: def __init__(self): n = 200 if True: j = 200
1
by: George2 | last post by:
Hello everyone, In the sample, I am wondering what is the life cycle of variable b_? Could we access variable b_ in catch block? I have this confusion is because, 1. I think b_ is member...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.