with undo "name" on - gc error

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

 
Thread Tools Display Modes
  4 Weeks Ago
with undo "name" on - gc error

Hello.
I'm trying to debug my 3.8k strings code in max2017 because of "garbage collect error" (2013,2016,2018 are okay) and I found a really strange thing.

This code will generate gc error in max2017 but not in other versions, it was checked by 3 different users with the same result (error).

(
   fn test = with undo "undo test" on (
      box()
      gc light:on
   )
   test()
   gc light:on
)


But this code doesn't generate error

(
   fn test = (
      box()
      gc light:on
   )
   test()
   gc light:on
)


Both of them will add undo record, but first one will name it. I know the code looks silly, why I need gc inside function and then do gc again. This is just an example to get error.
In my script there are many functions with named undo records. I tried to remove all "gc light:on" from functions and still had garbage collect errors after some operations.

Errors gone only when I removed all "with undo <name> on" and that's all...
Am I doing something wrong?

UPD.
This method works fine.

(
   fn test = (
      undo "undo test" on (
         box()
      )
      gc light:on
   )
   test()
   gc light:on
)


UPD 2.
One more test. This code generates gc error only in 2017. GC now is not even inside function. If I remove undo label ("undo record") then no error.

(
   fn createInsaneArray = (
      local verts = for v=1 to 85000 collect #()
   )
   fn testFn = undo "undo record" on (
      createInsaneArray()
      box()
   )
   
   for i=1 to 2 do testFn()
   gc light:on
)

I'm still interested why it was okay in 2016 and 2018, but not in 2017.
Forgot to mention that heapsize in all versions is 15MB. If I increase heapsize to 512MB then I need to run this testFn not 2 but 200 times to get gc error. Looks like a bug in 2017.

Last edited by NiK684 : 4 Weeks Ago at 08:47 AM.
 
  4 Weeks Ago
in general the using of theundo context with a function definition is not a good practice.
usuallyundo context has to be used with ui control events. (for example when a button is pressed)

there are many reasons for not using this context (as well as other: redraw, animate, etc.) with a function.
for example:
# not every call off this function has to be undoable
# in different situations the "accept string" might be different:

fn deletenodes nodes =(delete nodes)
on delete_cameras_bt pressed do undo "Delete Cameras" ondeletenodes cameras
on delete_helpers_bt pressed do undo "Delete Helpers" ondeletenodes helpers

# several functions might be combined under one undo
# undo might be canceled for any reason
etc...
 
  4 Weeks Ago
Thanks for an explanation, Denis.
Actually I fixed my script by using local undo scope inside functions and now it's better than before. And no errors.
Now I'm just curious why adding "name" to undo record generates GC error in some situations and only in max2017. Nobody interested in this outdated 3dsmax? I don't use it, but some users of my script do.

GC error only in max2017.

(
   fn createInsaneArray = local verts = for v=1 to 85000 collect #()
   fn testFn = box()

   createInsaneArray()
   undo "undo record" on (
      createInsaneArray()
      testFn()
   )
   gc light:on
)


No errors. Only one change - no undo record name.

(
   fn createInsaneArray = local verts = for v=1 to 85000 collect #()
   fn testFn = box()

   createInsaneArray()
   undo on (
      createInsaneArray()
      testFn()
   )
   gc light:on
)
 
reply share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 08:38 PM.


Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.