Re: Memory usage on Win32: Euphoria usage vs. what Task Manager displays
- Posted by DerekParnell (admin) Jul 31, 2009
- 952 views
Sorry, no dice.
I downloaded 4.03a and ran the code. It does not free the RAM on my system. This is Windows XP Pro. What were you using Derek?
I'm using Windows XP too.
I stand by my assertion that memory released by reducing the size a sequence is made available for reuse. If the amount of memory released is larger than the system page size, that memory can be reused by other applications.
I'm using two measurements to confirm this. Using the Windows system monitor, I'm looking at the Available Physical Memory (APM) and the "Mem Usage" (MU) for the eui.exe process.
As memory is allocated and assigned to the 'x' object, APM is decreasing and MU is increasing. When the 'x' object is assigned 0, APM is increases to (almost) the initial value, and MU decreases to (almost) its initial value. The residual amount I think is associated with the minimum allocation size for RAM (usually 4K or system page size).
Also, the time difference between concatenating and pre-allocating is negliable.
Here is my pre-allocation version
clear_screen() integer c object ch object x sequence t atom e c = 1 puts(1, "Begin?\n") ch = gets(0) t = repeat(0,1000) x = repeat(0, 50*500) puts(1, "Pre-allocation done\n") ch = gets(0) puts(1, "Allocating ...\n") e = time() for i = 1 to 50 do -- adjust if it grabs too much memory for your system ? i for j = 1 to 500 do for q = 1 to 1000 do t[q] = rand(1000) / rand(1000) end for x[c] = t c += 1 end for end for ? time() - e puts(1, "End of allocation\n") ch = gets(0) x = 0 puts(1, "X deferenced\n") ch = gets(0)
What about the Eu version? Are you using 4.03a or a more bleeding-edge version? Any super-recent changes to memory handling, garbage collection?
I don't think so.
Anyway, not only did it not free the RAM, but it used way more of it too. With the same code as before (my code, with the loops), when the counter is at 50 I get: 878,522K used, 200,000K more than before! And it doesn't free it either. After setting x = 0 (or x = {}, no difference), it only goes down to 780,696, still 100K more than the 3.1 version used maximum.
What are you using to measure this? I'm not seeing this effect at all.