Created
November 26, 2019 15:47
-
-
Save loretoparisi/41a0e9b85517289c6119e623157c02a9 to your computer and use it in GitHub Desktop.
Python Memory Test - take from https://napuzba.com/a/extend-memory-swap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/python | |
import ctypes | |
import sys | |
size = int(sys.argv[1]) | |
class MemoryTest(ctypes.Structure): | |
_fields_ = [ ('chars' , ctypes.c_char*size * 1024*1024 ) ] | |
try: | |
test = MemoryTest() | |
print('success => {0:>4}MB was allocated'.format(size) ) | |
except: | |
print('failure => {0:>4}MB can not be allocated'.format(size) ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment