Notifications
Clear all

[Closed] MXS unexplained problem… memory leaking

wow!
i found that is enough just call 3.0 anywhere to make everywhere stop the leaking
not 0.0, not 1.0, not 7.0 etc.
just 3.0 works!

(
	3.0 -------------------- !!!!!!!!!!!!!!!!!!!! ---------------------------
	pp = [1,2,3]
	t0 = timestamp()
	h0 = heapfree

	for k = 1 to 100000 do pp[3]

	format "time:% heap:%\n" (timestamp() - t0) (h0 - heapfree)
)

no leak!

THANK MAX FOR MAKING LIFE FUNNY

I have tested the code in your first post in 3ds Max 2014.
For 10 000 iterations:
[1,2,3]
time:5 heap:120L
OK

For 1 000 000 iterations:
1,2,3]
time:2543 heap:1326960L
OK

And when I put 3.0 at the begining of the script the result for 1 000 000 iterations:
[1,2,3]
time:306 heap:120L
OK

Then I removed the 3.0 from the code and for 1 000 000 iterations:
[1,2,3]
time:306 heap:120L
OK

So, do we have to put a script in startup folder with just 3.0 as a code in it to solve this probllem?

sounds like that

you see it! so i’m not crazy

it’s not a memory issue only. also the performance is different (but it’s expected because of the fact of memory leaking)

Yes, another “gem” from AD.

it’s more likely that this issue exists in many version (2012+ for sure). but many users cannot see it because of some startup scripts or scripted plugins which load on startup.

my MAX system is clean, I do not have any third-party tools at startup, and I also disable many of the built-in startup scripts (because neither I nor my clients use them).

I have put a script containing onli 3.0 as a code in my startup folder and now the proglem is gone.
I wonder what is the reason 3.0 to be the cure for this problem.

there is another issue similar to above:

(
	t0 = timestamp()
	h0 = heapfree

	for k = 1 to 10000 do k

	format "time:% heap:%\n" (timestamp() - t0) (h0 - heapfree)
)

this code starts leak if you change number of iterations to 100000 for example. the trick with “3.0” doesn’t help.
any other tricks we can find?

see the difference:

(
	t0 = timestamp()
	h0 = heapfree

	for i=1 to 1000 do for k = 1 to 1000 do k

	format "time:% heap:%\n" (timestamp() - t0) (h0 - heapfree)
)
(
	t0 = timestamp()
	h0 = heapfree

	for k = 1 to 1000000 do k

	format "time:% heap:%\n" (timestamp() - t0) (h0 - heapfree)
)

these are very usual ‘loops’ when we work with big meshes for example… the performance difference might be huge in many cases

i can’t remember all ‘similar’ loop issues, but there are many of them, including bitarray loops (iterators)
for example:

(
	t0 = timestamp()
	h0 = heapfree

	for k in #{1..1000000} do k

	format "time:% heap:%\n" (timestamp() - t0) (h0 - heapfree)
)
Page 2 / 3