1. Richard Lynskey
  2. PowerBuilder
  3. Monday, 01 October 2018

What are the most common things in PowerScript that consume memory without releasing it?

I'm trying to troubleshoot a window that is consuming memory at a level we were not expecting, and I'm honestly running out of ideas of what to even look for. I've read over various posts here and elsewhere over the years that you should either call Reset() or ResetUpdate() on a DataWindow for example (I've seen both, not sure if both will give the same ultimate result) and potentially even clearing the dataobject property itself, but they do not seem to be the culprit and I'm not sure where else to even begin.

Kevin Ridley Accepted Answer Pending Moderation
0
Votes
Undo

Most common cause I've found in code is creating objects and not destroying them.  You say you are clicking on a row and retrieving child rows, are you doing it in another window?  Is it possible you create a ds in the new window and don't destroy it, or another nvo maybe?  Check for any CREATE statements and make sure there is also a DESTROY.  Sometimes it's helpful to put the DESTROY in a finally block of a try/catch so you can be assured you're not exiting out (or erroring out) and missing the destroy.  Any use of arrays, like putting the data into an array?  If so, you can do something like:

String   ls_col1[], ls_null[]  

//populate your array, then finish with

ls_col1 = ls_null

 

If you are opening another window for the child retrieve, it sounds like that might be where to start looking.

 

Good luck.

Kevin

 

Comment
There are no comments made yet.
  1. Monday, 1 October 2018
  2. PowerBuilder
  3. # 1
Roland Smith Accepted Answer Pending Moderation
0
Votes
Undo

It sounds to me like one of the DataWindows might be retrieving too many rows. Perhaps one is retrieving several thousand rows but then filtering it down to a few rows.

Comment
There are no comments made yet.
  1. Monday, 1 October 2018
  2. PowerBuilder
  3. # 2
Chris Pollach Accepted Answer Pending Moderation
0
Votes
Undo

Hi Richard;

  For DWO's here is what I do in my code to fully release their memory ...

  • DC. Reset ( )
  • DC_DataObject = ""

For a DataStore

  • DS. Reset ( )
  • DS_DataObject = ""
  • Destroy

Here is a PB.INI setting that you can try ..

[DataStore Behavior]
; No = do NOT use MS-Window handles in DS processing (Default is yes). "No" gives much better performance!
UseHwnd=no

Regards ... Chris

Comment
There are no comments made yet.
  1. Monday, 1 October 2018
  2. PowerBuilder
  3. # 3
Roland Smith Accepted Answer Pending Moderation
0
Votes
Undo

You didn't say what version of PB you are using.

Creating objects in a loop could use a lot of memory. The GarbageCollect function can be used to release unused objects.

The memory manager will not release allocated memory back to the operating system. It allocates memory as needed and when it is finished with a block of memory, it marks it as free (internally) and will re-use it later.

There might be a memory management option that you can put in a pb.ini file but those aren't publicly documented anywhere except in forum posts.

 

Comment
Our production environment is 12.6 build 4098, and I've tried migrating up to 2017 R2 and R3 just to see if we saw any difference (we didn't).



And I do know the operating system doesn't immediately reclaim the released memory, in this case we've got a list datawindow that you click on a row which retrieves children, and we consistently have the process claim another 2-10mb of memory each time, eventually hitting the memory limit and then we crash.
  1. Richard Lynskey
  2. Monday, 1 October 2018
Hi Richard;

Roland is correct ... Using the GarbageCollect commands or waiting for the PBVM to perform Garbage Collection on PB only marks blocks of memory as "free" to re reused.



However, a neat little trick I used to use is to momentarily minimize the PB App (say on an IDLE event) by using the SEND command. If you send a Minimize to the MDI Frame window, do a a few yields and the then send he MDI Frame a "restore" command ... I have found that the PBVM would actually release memory that is marked as "free".



Note: I have not tested the above in 2017Rx.

HTH

Regards ... Chris

  1. Chris Pollach
  2. Monday, 1 October 2018
There are no comments made yet.
  1. Monday, 1 October 2018
  2. PowerBuilder
  3. # 4
  • Page :
  • 1


There are no replies made for this question yet.
However, you are not allowed to reply to this question.