Python | sys.getallocatedblocks() method Last Updated : 25 Jun, 2019 Comments Improve Suggest changes Like Article Like Report This sys module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter. It provides information about constants, functions and methods of python interpreter. It can be used for manipulating Python runtime environment. sys.getallocatedblocks() is used to get number of memory blocks currently allocated by the interpreter, regardless of their size. This function is mainly useful for tracking and debugging memory leaks. To get more predictable results, we may have to call _clear_type_cache() and gc.collect(). Syntax: sys.getallocatedblocks() Parameter: This method accepts no parameter. Return Value: This method returns the number of memory blocks currently allocated by the interpreter but if it cannot reasonably compute this information then 0 is returned. Example #1 : Using sys.getallocatedblocks() method to find the memory allocated to interpreter. Python3 1== # Python program to explain sys.getallocatedblocks() method # Importing sys module import sys # Using sys.getallocatedblocks() method memory = sys.getallocatedblocks() # Print result print(memory) Output: 20731 Comment More infoAdvertise with us Next Article Python | sys.getallocatedblocks() method R Rajnis09 Follow Improve Article Tags : Python Python-Functions Practice Tags : pythonpython-functions Similar Reads Python | sys.getswitchinterval() method This sys module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter. It provides information about constants, functions and methods of python interpreter. It can be used for manipulating Python runtime environment. sys. 1 min read Python | sys.getrecursionlimit() method This sys module provides access to some variables used or maintained by the interpreter and to functions that interact strongly with the interpreter. It provides information about constants, functions and methods of python interpreter. It can be used for manipulating Python runtime environment. sys. 1 min read Python | os.set_blocking() method OS module in Python provides functions for interacting with the operating system. OS comes under Pythonâs standard utility modules. This module provides a portable way of using operating system dependent functionality. os.set_blocking() method in Python is used to set the blocking mode of the specif 2 min read Python | os.getrandom() method OS module in Python provides functions for interacting with the operating system. OS comes under Pythonâs standard utility modules. This module provides a portable way of using operating system dependent functionality. os.getrandom() method is used to generate a string of size random bytes suitable 2 min read Python | os.getenvb() method OS module in Python provides functions for interacting with the operating system. OS comes under Pythonâs standard utility modules. This module provides a portable way of using operating system dependent functionality. os.getenvb() method in Python is bytes version of os.getenv() method. This method 3 min read Like