# 1.5Gb PHP process, lots of swap

- Thread: https://externals.io/message/19793
- Original archive: https://news-web.php.net/php.internals/19793
- Started by Cristiano Duarte on 2005-10-28T19:21:26+00:00
- Messages: 6
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #19793 — Cristiano Duarte — 2005-10-28T19:21:26+00:00

URL: https://externals.io/message/19793#19793

Is there any way to force a PHP CLI application to free the memory it took
from the system ? I mean, is there any PHP userland or PHP internal
functional call that could *really* free 'the memory allocated by a
variable' or 'the memory allocated but currently not used and waiting for
the script end to be freed' ?

Regards,

Cristiano Duarte

---

## #19795 — Andi Gutmans — 2005-10-28T20:23:44+00:00

URL: https://externals.io/message/19793#19795 · In reply to: #19793

Hi Cristiano,

Alex sent a patch to the list a while ago which forces the memory 
allocator to return memory to the system. However, in your case, I 
think you might be just having PHP variables "leaking". Can you try 
and identify where this info is sitting and try and unset it? It's 
important to dig deeper and/or reproduce in order to understand.


Andi

At 12:21 PM 10/28/2005, Cristiano Duarte wrote:
>Is there any way to force a PHP CLI application to free the memory it took
>from the system ? I mean, is there any PHP userland or PHP internal
>functional call that could *really* free 'the memory allocated by a
>variable' or 'the memory allocated but currently not used and waiting for
>the script end to be freed' ?
>
>Regards,
>
>Cristiano Duarte

---

## #19803 — Sebastian — 2005-10-29T01:50:26+00:00

URL: https://externals.io/message/19793#19803 · In reply to: #19795

Lexical variables would be nice.


> Hi Cristiano,
>
> Alex sent a patch to the list a while ago which forces the memory
> allocator to return memory to the system. However, in your case, I
> think you might be just having PHP variables "leaking". Can you try
> and identify where this info is sitting and try and unset it? It's
> important to dig deeper and/or reproduce in order to understand.
>
>
> Andi
>
> At 12:21 PM 10/28/2005, Cristiano Duarte wrote:
> > […]
>
> --
> 
> 
>
>


--



-------------
buddhahead@gmail.com

---

## #19806 — Andi Gutmans — 2005-10-29T05:14:43+00:00

URL: https://externals.io/message/19793#19806 · In reply to: #19803

What do you mean?

At 06:50 PM 10/28/2005, Sebastian wrote:
>Lexical variables would be nice.
>
>
> > […]
>
>
>--
>
>
>
>-------------
>buddhahead@gmail.com

---

## #19809 — Sebastian — 2005-10-29T06:41:25+00:00

URL: https://externals.io/message/19793#19809 · In reply to: #19806

Something like the variables produced by perl's my() operator so that
a variable is lexically scoped along with block-level scoping could
help earlier detection of when it's possible to release a variable.
This wouldn't solve leaks, but it might help prevent some


> What do you mean?
>
> At 06:50 PM 10/28/2005, Sebastian wrote:
> > […]
>
>


--



-------------
buddhahead@gmail.com

---

## #19819 — Andi Gutmans — 2005-10-29T18:50:34+00:00

URL: https://externals.io/message/19793#19819 · In reply to: #19809

Well in most cases, if your program isn't written in the global scope 
but has methods or functions, then local variables will be removed 
early enough. For situations where you need to force it I suggest to 
use unset(). It'd be ugly to add another scoping operator and in most 
cases it's not needed.

Regards,

Andi

At 11:41 PM 10/28/2005, Sebastian wrote:
>Something like the variables produced by perl's my() operator so that
>a variable is lexically scoped along with block-level scoping could
>help earlier detection of when it's possible to release a variable.
>This wouldn't solve leaks, but it might help prevent some
>
>
> > […]
> memory it took
> > […]
> and waiting for
> > […]
>
>
>--
>
>
>
>-------------
>buddhahead@gmail.com
