Sep-19-2016, 11:23 AM
Hi guys [Image: icon_e_smile.gif]
I am trying to write a simple proof-of-concept script on Windows 10 that let's me draw the absolute of a sin curve in the task manager memory window.
My code is as follows:
![[Image: ahEsx.png]](https://i.stack.imgur.com/ahEsx.png)
What I want is this:
![[Image: UXPYc.png]](https://i.stack.imgur.com/UXPYc.png)
I am not entirely sure what I am doing wrong, but I suspect it is something to do with the garbage collection in Python. I've extensively searched for the answer, but I didn't find anything that worked...
I hope you guys can help me. Thanks!
I am trying to write a simple proof-of-concept script on Windows 10 that let's me draw the absolute of a sin curve in the task manager memory window.
My code is as follows:
import time import math import gc import sys x = 1 string_drawer = [] while True: #Formula for the eqaution (sin curve) y = (abs(math.sin(math.radians(100*x))))*512000000 print (y, type(y)) #Making y type 'int' so that it can be used to append y = int(round(y)) print (y, type(y)) #Checking the size of string_drawer for debugging print(sys.getsizeof(string_drawer)) #Loop used for appending if sys.getsizeof(string_drawer) < y: #If y is bigger, find the difference and append y = y - sys.getsizeof(string_drawer) string_drawer.append(' ' *y) elif sys.getsizeof(string_drawer) > y: #If y is smaller, delete the variable and make a new one string_drawer = [] *y else: #If y is the same size as string_drawer, do nothing pass #Call the Python gerbage colector gc.collect() #Sleep to make sure Task Manager catches the change in RAM usage time.sleep(0.5) #Increment x x += 1 print(x, type(x))What I am getting is this:
![[Image: ahEsx.png]](https://i.stack.imgur.com/ahEsx.png)
What I want is this:
![[Image: UXPYc.png]](https://i.stack.imgur.com/UXPYc.png)
I am not entirely sure what I am doing wrong, but I suspect it is something to do with the garbage collection in Python. I've extensively searched for the answer, but I didn't find anything that worked...
I hope you guys can help me. Thanks!