Skip to content

Commit 14d743b

Browse files
authored
Merge pull request #27 from imsahil007/master
Create memory_usage.md
2 parents 98b2d02 + a5a679a commit 14d743b

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

snippets/python/memory_usage.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Memory Usage
2+
The memory used by an object inside a code can be checked by sys.getsizeof()
3+
4+
*tags:* python, memory, objects
5+
6+
### Syntax:
7+
```
8+
sys.getsizeof(object_name))
9+
```
10+
11+
### Snippet:
12+
```
13+
import sys
14+
15+
num = 21
16+
17+
print(sys.getsizeof(num))
18+
19+
# In Python 2, 24
20+
# In Python 3, 28
21+
```

0 commit comments

Comments
 (0)