<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">Using the C API, you need to maintain a reference to the JSContextGroupRef. One way to do that is to maintain a reference to the JSContextRef.<div class=""><br class=""></div><div class="">Geoff</div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Nov 28, 2016, at 3:33 PM, <a href="mailto:tevaum@gmail.com" class="">tevaum@gmail.com</a> wrote:</div><br class="Apple-interchange-newline"><div class=""><p dir="ltr" class="">Thanks, Geoff.</p><p dir="ltr" class="">One more thing, if I use JSRetainPtr for the context, what happens to the values when the context is destroyed? Does the value keep a reference of the context and the context won't be destroyed until all values are garbage collected? Or will the context be destroyed and the value will be in an invalid state, referencing an invalid context?</p>
<br class="gmail_msg"><div class="gmail_quote gmail_msg"><div dir="ltr" class="gmail_msg">On 18:24, Mon, Nov 28, 2016 Geoffrey Garen <<a href="mailto:ggaren@apple.com" class="gmail_msg" target="_blank">ggaren@apple.com</a>> wrote:<br class="gmail_msg"></div><blockquote class="gmail_quote gmail_msg" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><blockquote type="cite" class="gmail_msg"><div class="gmail_msg"><p dir="ltr" class="gmail_msg">So I'm asking you guys: what happens with values? Are they just garbage collected? Do they keep a reference of the context or the other way around? Is there a place where I can learn more about JSC besides the code? </p></div></blockquote></div></div><div style="word-wrap:break-word" class="gmail_msg"><div class="gmail_msg"><div class="gmail_msg">Values on the stack are garbage collected. If you store a reference to a value in the heap, you need to call JSValueProtect/JSValueUnprotect.</div></div><div class="gmail_msg"><br class="gmail_msg"></div><div class="gmail_msg">Geoff</div></div>
</blockquote></div>
</div></blockquote></div><br class=""></div></body></html>