<div dir="ltr">What can I do to prevent the `WebServer` instance from being garbage collected?<div>I thought this would work:</div><div><br></div><div>- make `server` be an instance variable of my `MyWebServer` class</div><div>- set that variable in the `initialize` method of that class to a new instance of `WebServer`</div><div>- create an instance of `MyWebServer` in a Workspace like this:</div><div><br></div><div>server := MyWebServer new.</div><div><br></div><div>That did not work. It seems the instance of `WebServer` that is supposedly held by the instance of `MyWebServer` still gets GCed.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, Jun 12, 2024 at 10:23 AM Juan Vuletich <<a href="mailto:juan@cuis.st">juan@cuis.st</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><u></u>

  
    
  
  <div bgcolor="#ffffff">
    Hi Mark,<br>
    <br>
    In Worspaces, variables not declared between vertical vars are
    "Workspace Variables" and live until the Workspace is closed.<br>
    In methods, variables declared as temporaries, between vertical
    vars, may be garbage collected anytime after the method exits,
    unless there is some other reference to the contents.<br>
    <br>
    So, yes. It is very possible that that's the difference.<br>
    <br>
    Cheers,<br>
    <br>
    On 6/12/2024 11:27 AM, Mark Volkmann via Cuis-dev wrote:
    <blockquote type="cite">
      <div dir="ltr">Is it possible the issue is that when I run the
        code from a Workspace, the server does not get garbage
        collected, but when I run it from within the `initialize`
        method, it does get garbage collected?</div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Tue, Jun 11, 2024 at
          8:42 PM Mark Volkmann <<a href="mailto:r.mark.volkmann@gmail.com" target="_blank">r.mark.volkmann@gmail.com</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
          <div dir="ltr">I created a class named `MyWebServer` and added
            this `initialize` method.
            <div><br>
            </div>
            <div><font face="monospace">initialize<br>
                    "demonstrates using the WebServer class"<br>
                <br>
                    server := WebServer new listenOn: 1961.<br>
                    server addService: '/' action: [ :req | req
                send200Response: 'Home Page' ].<br>
                    server addService: '/hello' action: [ :req | req
                send200Response: 'Hello World!' ]</font><br>
            </div>
            <div><br>
            </div>
            <div>Then I entered this in a Workspace and ran "Do it":</div>
            <div><br>
            </div>
            <div><font face="monospace">MyWebServer new</font></div>
            <div><br>
            </div>
            <div>This started a process named "WebServer's listener
              process" that I see in a Process Browser window.</div>
            <div><br>
            </div>
            <div>If I browse localhost:1961, the browser just hangs. But
              if I enter that same code in a Workspace, both routes work
              fine.</div>
            <div>What am I missing?</div>
          </div>
          <br>
          <div class="gmail_quote">
            <div dir="ltr" class="gmail_attr">On Tue, Jun 11, 2024 at
              7:24 PM Mark Volkmann <<a href="mailto:r.mark.volkmann@gmail.com" target="_blank">r.mark.volkmann@gmail.com</a>>
              wrote:<br>
            </div>
            <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">
              <div dir="ltr">Thank you so much! This is exactly what I
                was looking for.</div>
              <br>
              <div class="gmail_quote">
                <div dir="ltr" class="gmail_attr">On Tue, Jun 11, 2024
                  at 1:05 AM Bernhard Pieber via Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st" target="_blank">cuis-dev@lists.cuis.st</a>>
                  wrote:<br>
                </div>
                <blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex">Feature require: 'WebClient'.<br>
                  <br>
                  See class WebServer<br>
                  <br>
                  Cheers,<br>
                  Bernhard<br>
                  <br>
                  <br>
                  > Am 10.06.2024 um 14:39 schrieb Mark Volkmann via
                  Cuis-dev <<a href="mailto:cuis-dev@lists.cuis.st" target="_blank">cuis-dev@lists.cuis.st</a>>:<br>
                  > <br>
                  > Can someone recommend a package I should look at
                  to learn about implementing HTTP endpoints in Cuis?<br>
                  > <br>
                  > ---<br>
                  > R. Mark Volkmann<br>
                  > Object Computing, Inc.<br>
                  > --<br>
                  > Cuis-dev mailing list<br>
                  > <a href="mailto:Cuis-dev@lists.cuis.st" target="_blank">Cuis-dev@lists.cuis.st</a><br>
                  > <a href="https://lists.cuis.st/mailman/listinfo/cuis-dev" rel="noreferrer" target="_blank">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><br>
                  <br>
                  <br>
                  -- <br>
                  Cuis-dev mailing list<br>
                  <a href="mailto:Cuis-dev@lists.cuis.st" target="_blank">Cuis-dev@lists.cuis.st</a><br>
                  <a href="https://lists.cuis.st/mailman/listinfo/cuis-dev" rel="noreferrer" target="_blank">https://lists.cuis.st/mailman/listinfo/cuis-dev</a><br>
                </blockquote>
              </div>
              <br clear="all">
              <div><br>
              </div>
              <span class="gmail_signature_prefix">-- </span><br>
              <div dir="ltr" class="gmail_signature">
                <div dir="ltr">
                  <div>
                    <div dir="ltr">
                      <div>
                        <div dir="ltr">
                          <div dir="ltr">
                            <div><font face="arial, helvetica,
                                sans-serif">R. Mark Volkmann</font></div>
                            <div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">Object
                                  Computing, Inc.</font></span></div>
                          </div>
                        </div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </blockquote>
          </div>
          <br clear="all">
          <div><br>
          </div>
          <span class="gmail_signature_prefix">-- </span><br>
          <div dir="ltr" class="gmail_signature">
            <div dir="ltr">
              <div>
                <div dir="ltr">
                  <div>
                    <div dir="ltr">
                      <div dir="ltr">
                        <div><font face="arial, helvetica, sans-serif">R.
                            Mark Volkmann</font></div>
                        <div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">Object
                              Computing, Inc.</font></span></div>
                      </div>
                    </div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </blockquote>
      </div>
      <br clear="all">
      <div><br>
      </div>
      <span class="gmail_signature_prefix">-- </span><br>
      <div dir="ltr" class="gmail_signature">
        <div dir="ltr">
          <div>
            <div dir="ltr">
              <div>
                <div dir="ltr">
                  <div dir="ltr">
                    <div><font face="arial, helvetica, sans-serif">R.
                        Mark Volkmann</font></div>
                    <div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">Object
                          Computing, Inc.</font></span></div>
                  </div>
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </blockquote>
    <br>
    <br>
    <pre cols="72">-- 
Juan Vuletich
<a href="http://cuis.st" target="_blank">cuis.st</a>
<a href="http://github.com/jvuletich" target="_blank">github.com/jvuletich</a>
<a href="http://researchgate.net/profile/Juan-Vuletich" target="_blank">researchgate.net/profile/Juan-Vuletich</a>
<a href="http://independent.academia.edu/JuanVuletich" target="_blank">independent.academia.edu/JuanVuletich</a>
<a href="http://patents.justia.com/inventor/juan-manuel-vuletich" target="_blank">patents.justia.com/inventor/juan-manuel-vuletich</a>
<a href="http://linkedin.com/in/juan-vuletich-75611b3" target="_blank">linkedin.com/in/juan-vuletich-75611b3</a>
<a href="http://twitter.com/JuanVuletich" target="_blank">twitter.com/JuanVuletich</a></pre>
  </div>

</blockquote></div><br clear="all"><div><br></div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div><font face="arial, helvetica, sans-serif">R. Mark Volkmann</font></div><div><span style="font-size:12.8px"><font face="arial, helvetica, sans-serif">Object Computing, Inc.</font></span></div></div></div></div></div></div></div></div>