Windows 10에서 간단한 개념 증명 스크립트를 작성하여 작업 관리자 메모리 창에 죄 곡선의 절대 값을 그려 보겠습니다. 메모리에 사인 곡선 그리기 - Windows 10에서 작업 관리자보기 사용?
는 내가 원하는 것은 이것이다 : 다음과 같이 내가 얻고 것은
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
string_drawer = string_drawer
#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))
다음과 같이
내 코드는
당신의 아이디어를 가지고 있습니까 무엇을 내가 잘못하고있는거야? 내 생각 엔 if 루프 또는 가비지 컬렉터와 관련된 것입니다.
도움을 주시면 감사하겠습니다. 감사합니다 :)