Saturday, November 16, 2024
Google search engine
HomeLanguagesPython | sys.getallocatedblocks() method

Python | sys.getallocatedblocks() 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.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.




# 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

Last Updated :
25 Jun, 2019
Like Article
Save Article

<!–

–>

Similar Reads
Related Tutorials
Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments