Notifications
Clear all

[Closed] MXS unexplained problem… memory leaking

look at this snippet:

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

	for k=1 to 10000 do
	(
		pp[3]
	)

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

the result is for my machine:
time:3 heap:120L

but if we change the number of iterations to 100000 the result is:
time:39 heap:5792256L

for many years i can’t find explanation to this memory leaking.

does anyone have any idea what can it cause?

31 Replies

you can check these two examples which do the same number of iterations (1000000), but results are different including time:

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

	for i=1 to 100 do for k=1 to 10000 do pp[3]
	format "time:% heap:%\n" (timestamp() - t0) (h0 - heapfree)
)
(
	t0 = timestamp()
	h0 = heapfree

	for k=1 to 1000000 do pp[3]
	format "time:% heap:%\n" (timestamp() - t0) (h0 - heapfree)
)

it must be recent as the leak doesn’t exist in 2010

time:62 heap:68L with the count set to 100000

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

does it not leak with 1000000 as well?

not even with 10000000

time:6733 heap:68L

hmm… so it looks like a fatal improvement

It must be something on your end. Tested on Max 2010 to 2019 and the results are pretty much the same, no leak at all with 10M iterations.

time:959 heap:136L

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

hmm… looks like that.

both my machines (office and home) have this issue in max 2016, but only office machine has it in max 2018.
settings are identical of course. same plugin set… same windows.

i’m pretty sure i have seen this issue during many last years. from max 2012 for sure…

there is no idea how it might happen

hi denis, i run your test code and the leak doesnt occur here. heap:128L with 10000 to 10M iterations.
but anyway i remember this kind of memory leaking happened to me long time ago, i suspect it is caused by an unhealthy script which run first or active in the background… or could be related to my old thread :

a little bit off topic, related to my old thread, there was a revisions then i rebuild the GUI (dotnet form) and somehow that GC error was gone but the memory leaking is still there with smaller increment number. still never understand what was the real problem.

I could finally reproduce it in Max 2012 and 2013.

Could not find a fix for this in Max 2012, but weirdly, in Max 2013, deactivating “Load/Save Scene Scripts” in Preference Settings -> MaxScript -> Startup did completely solve the leak.

thanks Jorge… for the proving that i’m not crazy

it’s very weird thing… i couldn’t find any relation to plugins or scripts i have. as well as no relation to memory setup.
it just happens on some machines and versions, and it doesn’t on another

i showed an example with point3 access, but it happens also with another operations in a loop. the number of iterations is different and depends on “loop body” content

for example:

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

	for k = 1 to 100000 do pp[3]

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

this leaks… but if you change pp[3] in the loop to pp[1] it stops leak. which doesn’t make any sense.

also if you define pp at the beginning as pp = [1.0,2.0,3.0], it also doesn’t leak and… not any similar example leaks anymore after that!

ha-ha-ha…

when i add to my startup script only one line:

[1.0, 2.0, 3.0]

all my cases stop leak!

but if i add:

[0.0, 0.0, 0.0]
-- or [1.0,1.0,1.0]

it continues to leak. until i call [1.0,2.0,3.0] (or any not 0.0 or 1.0 float) in any place of my code!

Page 1 / 3