Skip to content

Instantly share code, notes, and snippets.

@loretoparisi
Created November 26, 2019 15:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loretoparisi/41a0e9b85517289c6119e623157c02a9 to your computer and use it in GitHub Desktop.
Save loretoparisi/41a0e9b85517289c6119e623157c02a9 to your computer and use it in GitHub Desktop.
Python Memory Test - take from https://napuzba.com/a/extend-memory-swap
#! /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