#48434 [Bgs]: memory function

2009-05-30 Thread busia at tiscali dot it
 ID:  48434
 User updated by: busia at tiscali dot it
 Reported By: busia at tiscali dot it
 Status:  Bogus
 Bug Type:Feature/Change Request
 PHP Version: 5.3.0RC2
 New Comment:

Look this code:


-
That show

a - 201640
b - 774800
c - 685360
d - 685360

If it is as you said the output near "d" should be different from the
output near "c" but they are identical. I want to know how many internal
mamory is used from the "$foo" variable. I know the the system memory is
the same because php don't make always garbage collection but it collect
on the request end bue i want to be able to know how much memory is
interested by section of code. Using your code seems that $foo is
registered on the void.

Thanks


Previous Comments:


[2009-05-30 13:29:54] scott...@php.net

What aren't you understanding?

memory_get_usage(true) = memory allocated to process from system
memory_get_usage() = memory actually in use for PHP

Therefore
memory_get_usage(true) - memory_get_usage()

That's the memory that has been allocated from the system but isn't
used for variables yet.



[2009-05-30 13:00:52] busia at tiscali dot it

I unsderstand what you say but my request is different: when I posted
bug #48368, j...@php.net answered me:

unset != free. The memory is freed once the process shuts down. Until 
that, it's available inside the process. This is not a leak.


I need a function that tell me the amount of this memory "available
inside the process" or even better the difference between
memory_get_usage() and this memory "available inside the process".

I don't think this is bogus, i think this must be an "open" feature
request.

Thanks



[2009-05-30 12:23:24] lbarn...@php.net

scott you are right, however it seems the behavior differs a bit when
unset()ing small-enough variables.

memory_get_usage(false) does not takes into account the "small blocks
cache" used by the allocator (not the same as the malloc()ed blocks
cache).

This causes the reported memory usage to not always decrease when
unset()ing a variable:



int(91448) <-- first call
int(91696) <-- before unset
int(91696) <-- after unset (== before unset)

This patch may fix this:
Index: Zend/zend_alloc.c
===
RCS file: /repository/ZendEngine2/zend_alloc.c,v
retrieving revision 1.144.2.3.2.43.2.23
diff -u -p -r1.144.2.3.2.43.2.23 zend_alloc.c
--- Zend/zend_alloc.c   1 Apr 2009 16:55:47 -   1.144.2.3.2.43.2.23
+++ Zend/zend_alloc.c   30 May 2009 12:12:48 -
@@ -2496,7 +2496,11 @@ ZEND_API size_t zend_memory_usage(int re
if (real_usage) {
return AG(mm_heap)->real_size;
} else {
-   return AG(mm_heap)->size;
+   size_t usage = AG(mm_heap)->size;
+#if ZEND_MM_CACHE
+   usage -= AG(mm_heap)->cached;
+#endif
+   return usage;
}
 }




[2009-05-30 11:42:31] scott...@php.net

memory_get_usage(true) is the memory allocated from the system.
memory_get_usage() is the memory currently in use by PHP.

http://bugs.php.net/48434

-- 
Edit this bug report at http://bugs.php.net/?id=48434&edit=1



#48434 [Bgs]: memory function

2009-05-30 Thread scottmac
 ID:  48434
 Updated by:  scott...@php.net
 Reported By: busia at tiscali dot it
 Status:  Bogus
 Bug Type:Feature/Change Request
 PHP Version: 5.3.0RC2
 New Comment:

What aren't you understanding?

memory_get_usage(true) = memory allocated to process from system
memory_get_usage() = memory actually in use for PHP

Therefore
memory_get_usage(true) - memory_get_usage()

That's the memory that has been allocated from the system but isn't
used for variables yet.


Previous Comments:


[2009-05-30 13:00:52] busia at tiscali dot it

I unsderstand what you say but my request is different: when I posted
bug #48368, j...@php.net answered me:

unset != free. The memory is freed once the process shuts down. Until 
that, it's available inside the process. This is not a leak.


I need a function that tell me the amount of this memory "available
inside the process" or even better the difference between
memory_get_usage() and this memory "available inside the process".

I don't think this is bogus, i think this must be an "open" feature
request.

Thanks



[2009-05-30 12:23:24] lbarn...@php.net

scott you are right, however it seems the behavior differs a bit when
unset()ing small-enough variables.

memory_get_usage(false) does not takes into account the "small blocks
cache" used by the allocator (not the same as the malloc()ed blocks
cache).

This causes the reported memory usage to not always decrease when
unset()ing a variable:



int(91448) <-- first call
int(91696) <-- before unset
int(91696) <-- after unset (== before unset)

This patch may fix this:
Index: Zend/zend_alloc.c
===
RCS file: /repository/ZendEngine2/zend_alloc.c,v
retrieving revision 1.144.2.3.2.43.2.23
diff -u -p -r1.144.2.3.2.43.2.23 zend_alloc.c
--- Zend/zend_alloc.c   1 Apr 2009 16:55:47 -   1.144.2.3.2.43.2.23
+++ Zend/zend_alloc.c   30 May 2009 12:12:48 -
@@ -2496,7 +2496,11 @@ ZEND_API size_t zend_memory_usage(int re
if (real_usage) {
return AG(mm_heap)->real_size;
} else {
-   return AG(mm_heap)->size;
+   size_t usage = AG(mm_heap)->size;
+#if ZEND_MM_CACHE
+   usage -= AG(mm_heap)->cached;
+#endif
+   return usage;
}
 }




[2009-05-30 11:42:31] scott...@php.net

memory_get_usage(true) is the memory allocated from the system.
memory_get_usage() is the memory currently in use by PHP.

http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

It's already there.
memory_get_usage() and memory_get_usage(true)





The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
http://bugs.php.net/48434

-- 
Edit this bug report at http://bugs.php.net/?id=48434&edit=1



#48434 [Bgs]: memory function

2009-05-30 Thread busia at tiscali dot it
 ID:  48434
 User updated by: busia at tiscali dot it
 Reported By: busia at tiscali dot it
 Status:  Bogus
 Bug Type:Feature/Change Request
 PHP Version: 5.3.0RC2
 New Comment:

I unsderstand what you say but my request is different: when I posted
bug #48368, j...@php.net answered me:

unset != free. The memory is freed once the process shuts down. Until 
that, it's available inside the process. This is not a leak.


I need a function that tell me the amount of this memory "available
inside the process" or even better the difference between
memory_get_usage() and this memory "available inside the process".

I don't think this is bogus, i think this must be an "open" feature
request.

Thanks


Previous Comments:


[2009-05-30 12:23:24] lbarn...@php.net

scott you are right, however it seems the behavior differs a bit when
unset()ing small-enough variables.

memory_get_usage(false) does not takes into account the "small blocks
cache" used by the allocator (not the same as the malloc()ed blocks
cache).

This causes the reported memory usage to not always decrease when
unset()ing a variable:



int(91448) <-- first call
int(91696) <-- before unset
int(91696) <-- after unset (== before unset)

This patch may fix this:
Index: Zend/zend_alloc.c
===
RCS file: /repository/ZendEngine2/zend_alloc.c,v
retrieving revision 1.144.2.3.2.43.2.23
diff -u -p -r1.144.2.3.2.43.2.23 zend_alloc.c
--- Zend/zend_alloc.c   1 Apr 2009 16:55:47 -   1.144.2.3.2.43.2.23
+++ Zend/zend_alloc.c   30 May 2009 12:12:48 -
@@ -2496,7 +2496,11 @@ ZEND_API size_t zend_memory_usage(int re
if (real_usage) {
return AG(mm_heap)->real_size;
} else {
-   return AG(mm_heap)->size;
+   size_t usage = AG(mm_heap)->size;
+#if ZEND_MM_CACHE
+   usage -= AG(mm_heap)->cached;
+#endif
+   return usage;
}
 }




[2009-05-30 11:42:31] scott...@php.net

memory_get_usage(true) is the memory allocated from the system.
memory_get_usage() is the memory currently in use by PHP.

http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

It's already there.
memory_get_usage() and memory_get_usage(true)





[2009-05-30 09:33:08] busia at tiscali dot it

Description:

You said me (#48368) that unset != free. The memory can remain occupied
also after I unset an array, that memory is reused when I set a new
variable and, for this reason, it's not a leak. Ok, now it's clear but a
problem remains: how can I optimize my code when I cannot see the php
internal memory use? I need a function like:

memory_get_usage() -
memory_allocated_but_usable_for_newly_created_variables();

Setting a variable and seeing that memory use don't change make scripts
impossible to optimize.

Thanks






-- 
Edit this bug report at http://bugs.php.net/?id=48434&edit=1



#48434 [Bgs]: memory function

2009-05-30 Thread lbarnaud
 ID:  48434
 Updated by:  lbarn...@php.net
 Reported By: busia at tiscali dot it
 Status:  Bogus
 Bug Type:Feature/Change Request
 PHP Version: 5.3.0RC2
 New Comment:

scott you are right, however it seems the behavior differs a bit when
unset()ing small-enough variables.

memory_get_usage(false) does not takes into account the "small blocks
cache" used by the allocator (not the same as the malloc()ed blocks
cache).

This causes the reported memory usage to not always decrease when
unset()ing a variable:



int(91448) <-- first call
int(91696) <-- before unset
int(91696) <-- after unset (== before unset)

This patch may fix this:
Index: Zend/zend_alloc.c
===
RCS file: /repository/ZendEngine2/zend_alloc.c,v
retrieving revision 1.144.2.3.2.43.2.23
diff -u -p -r1.144.2.3.2.43.2.23 zend_alloc.c
--- Zend/zend_alloc.c   1 Apr 2009 16:55:47 -   1.144.2.3.2.43.2.23
+++ Zend/zend_alloc.c   30 May 2009 12:12:48 -
@@ -2496,7 +2496,11 @@ ZEND_API size_t zend_memory_usage(int re
if (real_usage) {
return AG(mm_heap)->real_size;
} else {
-   return AG(mm_heap)->size;
+   size_t usage = AG(mm_heap)->size;
+#if ZEND_MM_CACHE
+   usage -= AG(mm_heap)->cached;
+#endif
+   return usage;
}
 }



Previous Comments:


[2009-05-30 11:42:31] scott...@php.net

memory_get_usage(true) is the memory allocated from the system.
memory_get_usage() is the memory currently in use by PHP.

http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

It's already there.
memory_get_usage() and memory_get_usage(true)





[2009-05-30 09:33:08] busia at tiscali dot it

Description:

You said me (#48368) that unset != free. The memory can remain occupied
also after I unset an array, that memory is reused when I set a new
variable and, for this reason, it's not a leak. Ok, now it's clear but a
problem remains: how can I optimize my code when I cannot see the php
internal memory use? I need a function like:

memory_get_usage() -
memory_allocated_but_usable_for_newly_created_variables();

Setting a variable and seeing that memory use don't change make scripts
impossible to optimize.

Thanks






-- 
Edit this bug report at http://bugs.php.net/?id=48434&edit=1



#48434 [Bgs]: memory function

2009-05-30 Thread scottmac
 ID:  48434
 Updated by:  scott...@php.net
 Reported By: busia at tiscali dot it
 Status:  Bogus
 Bug Type:Feature/Change Request
 PHP Version: 5.3.0RC2
 New Comment:

memory_get_usage(true) is the memory allocated from the system.
memory_get_usage() is the memory currently in use by PHP.

http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

It's already there.
memory_get_usage() and memory_get_usage(true)





[2009-05-30 09:33:08] busia at tiscali dot it

Description:

You said me (#48368) that unset != free. The memory can remain occupied
also after I unset an array, that memory is reused when I set a new
variable and, for this reason, it's not a leak. Ok, now it's clear but a
problem remains: how can I optimize my code when I cannot see the php
internal memory use? I need a function like:

memory_get_usage() -
memory_allocated_but_usable_for_newly_created_variables();

Setting a variable and seeing that memory use don't change make scripts
impossible to optimize.

Thanks






-- 
Edit this bug report at http://bugs.php.net/?id=48434&edit=1



#48434 [Bgs]: memory function

2009-05-30 Thread busia at tiscali dot it
 ID:  48434
 User updated by: busia at tiscali dot it
 Reported By: busia at tiscali dot it
 Status:  Bogus
 Bug Type:Feature/Change Request
 PHP Version: 5.3.0RC2
 New Comment:

I know memory_get_usage() and memory_get_usage(true). But they don't
resolve the problem because the memory is not freed always when I unset
a variable than memory_get_usage can return the same before and after
creating a variable. See #48368. You said me that internal php memory is
different from system allocated memory, and I want to access internal
php memory. Memory_get_usage (with or without the first parameter) allow
only to access to syem allocated memory.

Please reply


Previous Comments:


[2009-05-30 10:01:50] scott...@php.net

Sorry, but your problem does not imply a bug in PHP itself.  For a
list of more appropriate places to ask for help using PHP, please
visit http://www.php.net/support.php as this bug system is not the
appropriate forum for asking support questions.  Due to the volume
of reports we can not explain in detail here why your report is not
a bug.  The support channels will be able to provide an explanation
for you.

Thank you for your interest in PHP.

It's already there.
memory_get_usage() and memory_get_usage(true)





[2009-05-30 09:33:08] busia at tiscali dot it

Description:

You said me (#48368) that unset != free. The memory can remain occupied
also after I unset an array, that memory is reused when I set a new
variable and, for this reason, it's not a leak. Ok, now it's clear but a
problem remains: how can I optimize my code when I cannot see the php
internal memory use? I need a function like:

memory_get_usage() -
memory_allocated_but_usable_for_newly_created_variables();

Setting a variable and seeing that memory use don't change make scripts
impossible to optimize.

Thanks






-- 
Edit this bug report at http://bugs.php.net/?id=48434&edit=1