Skip to content

Commit 3160b14

Browse files
authored
Added memory management doc
1 parent 207c349 commit 3160b14

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

doc/memory-management.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
[<-- Return to index](../README.md)
2+
# Memory Management
3+
4+
### How is memory handled?
5+
#### PHP
6+
PHP is a managed memory environment, meaning it will automatically allocate and deallocate memory space as necessary without any specific thought necessarily being given by the user.
7+
#### Python
8+
Likewise, Python is also a managed memory environment. The language environment will manage memory as necessary on its own, and requires no explicit programmatic consideration for day-to-day code.
9+
10+
### How does memory management work?
11+
#### PHP
12+
PHP uses the [Zend Memory Manager](https://secure.php.net/manual/en/internals2.memory.php) to act as a go-between for PHP's requests for memory space and the traditional C libraries for asking the operating system for resources.
13+
#### Python
14+
Python uses the [Python Memory Manager](https://docs.python.org/3/c-api/memory.html) to act as a go-between for the language and the OS-level memory allocation layer.
15+
16+
### Is there a garbage collection service?
17+
#### PHP
18+
[Yes](https://secure.php.net/manual/en/features.gc.php)
19+
#### Python
20+
[Yes](https://docs.python.org/3/library/gc.html), and is directly accessible at the module level.
21+
22+
### Is there automatic reference counting?
23+
#### PHP
24+
[Yes](https://secure.php.net/manual/en/features.gc.refcounting-basics.php). PHP stores the reference count internally in an `refcount` variable inside a `zval` container attached to all variables.
25+
#### Python
26+
[Yes](https://docs.python.org/2.0/ext/refcounts.html), the memory manager will automatically return an objects memory space to the OS-level if its reference count reaches zero.

0 commit comments

Comments
 (0)