Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # $Id: malloc.py 1432 2010-09-29 10:13:16Z santi $
- import sys
- # Python >= 2.5 incluye la libreria *ctypes* el core, comprobar que esta disponible
- try:
- from ctypes import CDLL
- except ImportError:
- print 'ERROR! La libreria *ctypes* para Python no esta disponible!'
- sys.exit(-1)
- libc = CDLL('libc.so.6')
- n = 0
- while True:
- n = n + 1
- p = libc.malloc(n * 1024 * 1024)
- if p:
- print '%d MB' % n
- libc.free(p)
- else:
- print 'Limite de memoria alcanzado para malloc() => %d MB' % n
- sys.exit(-1)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement