objects: delete an object, but sub-objects (subkeys) remain

Get help with using AutoHotkey and its commands and hotkeys
User avatar
Posts: 6902
Joined: 19 Dec 2016, 01:58
Location: UK

objects: delete an object, but sub-objects (subkeys) remain

09 May 2017, 14:26

It says in the documentation that we can free objects via obj := "" e.g.
https://autohotkey.com/docs/Objects.htm ... ng_Objects

But does it actively encourage users to free objects anywhere in the documentation?

Also, is the behaviour below to be expected? It appears that if you delete an object, its subkeys / sub-objects are not deleted.

Code: Select all

q:: ;obj is deleted, but descendant of obj, obj.a.b, survives
obj := {}
obj["a","b","c"] := "ABC"
MsgBox, % IsObject(obj.a) IsObject(obj.a.b) IsObject(obj.a.b.c)
address := Object(obj.a.b)
obj := ""
obj2 := Object(address)
MsgBox, % obj2.c
obj2 := ""
homepage | tutorials | wish list | fun threads | donate
WARNING: copy your posts/messages before hitting Submit as you may lose them due to CAPTCHA
Posts: 4663
Joined: 17 Jul 2016, 01:02

Re: objects: delete an object, but sub-objects (subkeys) remain

09 May 2017, 15:24

You are at least encouraged to use ObjRelease, when appropriate. Your script behaves as expected, again, see reference counting, from begining until end.

Cheers ☕

Return to “Ask For Help”

Who is online

Users browsing this forum: arczi_87, Bing [Bot], Google [Bot], inseption86, one1tick, Smile_, teadrinker, XMCQCX and 53 guests