NetTalk Central

Author Topic: Memory issue - Solved?  (Read 3902 times)

Graham

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Memory issue - Solved?
« on: April 15, 2020, 01:32:51 AM »
Hi All

NT 11.35, StringTheory 3.21

Books Example Web71 - In the browser, app works fine...

Select WebServer App window:

 - click on a GET item in log - no problem
 - click on a POST item a few times, memory use goes thru the roof

See video: https://youtu.be/oPaN4feq3v8

Anyone else see this...

Thanks
Graham
« Last Edit: April 19, 2020, 03:44:50 AM by Graham »

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11186
    • View Profile
Re: Memory issue?
« Reply #1 on: April 16, 2020, 11:15:43 PM »
yes, I've seen this, but I don't think it's a NetTalk thing.
I think it's something to do with you clicking on the WebServer window itself.
Perhaps do the test again, but _don't_ click on the webserver window.

If that narrows down the scope of the issue, we can move to the next step...

Bruce

Graham

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: Memory issue - Solved?
« Reply #2 on: April 19, 2020, 03:44:26 AM »
Hi Bruce

Correct, I am clicking on the WebServer window - I would like to see the POST data

Specifically, it only happens when I click on a POST log entry where the _thread_ is 0 - believe this is just the POST Header.

In Netweb.clw, around line 686

            self.AddLog(self._ConnectionDataQueue.Data[1:x],self.packet.FromIP)

Problem goes away if I change this line with this:  "[1:x-1]"

            self.AddLog(self._ConnectionDataQueue.Data[1:x-1],self.packet.FromIP)

Not sure if that will break something further along - doesn't appear to...?

Have no idea what is at the end of the string to cause it to lose it's marbles like that

Cheers
Graham

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11186
    • View Profile
Re: Memory issue - Solved?
« Reply #3 on: April 20, 2020, 12:18:44 AM »
thanks Graham - I've made the tweak.
It'll exclude the <13> which was in position x, which should do no harm.
(It should do no harm being there either, but hey, if removing it helps...)

cheers
Bruce

jslarve

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Re: Memory issue - Solved?
« Reply #4 on: April 23, 2020, 12:33:35 AM »
Good find, Graham. I wonder if that <13> was confusing the ?Web:LastPost TEXT control on the WebServer window.

Will check that out tomorrow.

I was dealing with this for several hours today, but didn't discover the actual cause.

https://www.screencast.com/t/0j7Xm8Pb2R

When I commented out the one line, it stopped locking up. But I didn't take note of the memory usage.

If Field() = ?LogQueue and Event() = Event:NewSelection
      Get(LogQueue,Choice(?LogQueue))
      If ErrorCode() = 0
        Case Upper(Sub(LogQueue.Desc,1,3))
        Of 'POS'
          web:LastPost = LogQueue.Desc !This line locks up.
        Of 'GET'
          web:LastGet = LogQueue.Desc
        Else
          web:LastGet = LogQueue.Desc
        End
        Display()
      End
    End



thanks Graham - I've made the tweak.
It'll exclude the <13> which was in position x, which should do no harm.
(It should do no harm being there either, but hey, if removing it helps...)

cheers
Bruce

Graham

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: Memory issue - Solved?
« Reply #5 on: April 23, 2020, 04:35:44 AM »
Hi Jeff

Yip, that's what I was running into and it only happens if you touch the POST with thread number 0 which is the POST Header

App appears to lock up but if you leave it long enough, it comes back (sort of) but Ram used has gone thru the roof and impossible to use after that.

Think its actually a <10> - this is the code:

        x = instring ('<13,10><13,10>', self._ConnectionDataQueue.Data[1 : self._ConnectionDataQueue.DataLen], 1, pos)  ! Look for request terminating character
        if x > 0
          ! Found Header End Marker
          self._ConnectionDataQueue.HeaderEndPosition = x + 3

Cheers
Graham

Jane

  • Sr. Member
  • ****
  • Posts: 350
  • Expert on nothing with opinions on everything.
    • View Profile
    • Email
Re: Memory issue - Solved?
« Reply #6 on: April 23, 2020, 06:56:23 AM »
Thanks for figuring this out, guys!

My non-analytical mind just noticed that sometimes clicking in that list box invoked the spinning cursor symbol of death, so I've just steered away completely from doing that for the past year or more.  Never realized it was specific to POSTs.

Good catch!

Cheers,

Jane

jslarve

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Re: Memory issue - Solved?
« Reply #7 on: April 23, 2020, 08:04:04 AM »
Hi Graham -

On my machine it's a lone <13> (0dh) without the <10>.

I tried saving the offending string to a file and duplicating the error by assigning to a TEXT control in a test app, but it didn't exhibit the offending behavior. So I guess there's more to the circumstance than just the <13>. But I am glad you figured out how to get around it.


Hi Jeff

Yip, that's what I was running into and it only happens if you touch the POST with thread number 0 which is the POST Header

App appears to lock up but if you leave it long enough, it comes back (sort of) but Ram used has gone thru the roof and impossible to use after that.

Think its actually a <10> - this is the code:

        x = instring ('<13,10><13,10>', self._ConnectionDataQueue.Data[1 : self._ConnectionDataQueue.DataLen], 1, pos)  ! Look for request terminating character
        if x > 0
          ! Found Header End Marker
          self._ConnectionDataQueue.HeaderEndPosition = x + 3

Cheers
Graham

jslarve

  • Newbie
  • *
  • Posts: 29
    • View Profile
    • Email
Re: Memory issue - Solved?
« Reply #8 on: April 23, 2020, 08:18:46 AM »
Until the next NT build I went with this, just in case x might equal 1 some time.

        IF x > 1
                self.AddLog(self._ConnectionDataQueue.Data[1:x-1],self.packet.FromIP)
        ELSE
                self.AddLog(self._ConnectionDataQueue.Data[1:x],self.packet.FromIP)
        END


Hi Bruce

Correct, I am clicking on the WebServer window - I would like to see the POST data

Specifically, it only happens when I click on a POST log entry where the _thread_ is 0 - believe this is just the POST Header.

In Netweb.clw, around line 686

            self.AddLog(self._ConnectionDataQueue.Data[1:x],self.packet.FromIP)

Problem goes away if I change this line with this:  "[1:x-1]"

            self.AddLog(self._ConnectionDataQueue.Data[1:x-1],self.packet.FromIP)

Not sure if that will break something further along - doesn't appear to...?

Have no idea what is at the end of the string to cause it to lose it's marbles like that

Cheers
Graham

DonRidley

  • Don Ridley
  • Global Moderator
  • Hero Member
  • *****
  • Posts: 729
  • donaldridley2011@gmail.com
    • View Profile
    • Email
Re: Memory issue - Solved?
« Reply #9 on: April 27, 2020, 04:21:59 AM »
Some feedback on this topic...

I had been observing some weird memory use issues for quite a while.  My multi-site host apps would steadily use more and more memory until I would have to restart the apps.  I usually had to do this every 2 or 3 days.   Went through the app and optimized everything I thought could contribute to the issue.

I added Jeff's code and the memory issue has disappeared.  I tested the app with the web strain app and the memory was actually LESS than before the strain test!! 

After several days of continuous use, my apps have maintained a consistent and expected memory use.

Thank you Graham for finding this!!  It has been a thorn in my side for quite a while!

Don
"Eliminate the impossible, whatever remains, however unlikely, must be the truth."

NetTalk 12.55
Clarion 11

Graham

  • Jr. Member
  • **
  • Posts: 57
    • View Profile
Re: Memory issue - Solved?
« Reply #10 on: April 27, 2020, 10:29:47 PM »
Hi Don

Good to hear your issue resolved - just happy to have found a solution for my own sanity <g>

A few months ago, I posted re: Connections growing issue I was seeing - http://www.nettalkcentral.com/forum/index.php?topic=8434.msg34352#msg34352

Updated this app with this change and so far, so good.

Graham