Re: C vs PHP

From: Date: Sun, 25 Feb 2001 00:41:22 +0000
Subject: Re: C vs PHP
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-41524@lists.php.net to get a copy of this message
http://www.zend.com/zend/art/under-php4-hood.php and http://www.zend.com/zend/art/ref-count.php are articles that go into a bit more depth on this topic. Maybe not as detailed as you'd like, but they explain a bit more about how/why "PHP does it for you" is a valid reply to your question. Gustavo Vieira Goncalves Coelho Rios wrote: > Hi folks! > > I am a used C programmer and now my company decide to switch every non > performance critical web stuf to php. Since i am just a php beginner i > have some questions i could not find anywhere! > > As you may know, C does not provide any kind of support for garbage > collection, every thing you want to be done you have to tell (in C) by > yourself. But in PHP i have no ideia about how it manages memory. for > instance: > > In C: > > str = (char *) malloc(10u); > > if i decide to alloc new memory for str (just for explanation purposes), > and i do: > > str = (char *) malloc(33u); > > i would be in trouble, cause the reference for the previous allocated > pool of memory would be lost. > The approach could be to save the previous references or use realloc. > > Now, my doubt: How PHP deals with this: > > $query = "select * from apm where id=3"; > > /* do my processing */ > > /* and set query to a new string */ > > $query = "Query done without errors"; > > What will happen with the previous allocated memory for $query? > I don't like my application eating memory without releasing it after > they are no need any more. > > May some one explain how to prevent such scenarios ? > > Thanks a lot for your time and cooperation. > > best regrads. > > Gustavo Rios > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#41524) next »