1. Michael Kramer
  2. PowerBuilder
  3. Wednesday, 22 May 2019 10:10 AM UTC

Hi All,

Is "physical location" of images loaded using .PBR files cached similar to location of classes and DataWindow objects?

First time app needs to loads any class from disk, it searches the library list. When found, loads from disk and caches location for future loads. Next time class needs to load from disk, PB runtime doesn't search library list for the class. Instead, loads from previously found library.

Does anyone know whether PB also caches the location of image files linked into .PBD files using .PBR files? I would expect so but honestly never tested this particular combo.

Thanks in advance, /Michael
(Inspired by a discussion at the German user group conference earlier this week)

Accepted Answer
Michael Kramer Accepted Answer Pending Moderation
  1. Saturday, 22 June 2019 02:23 AM UTC
  2. PowerBuilder
  3. # Permalink

I have now tested as suggested by Roland. I see that image position is NOT cached - contrary to expectations. SO I want to share my learning.

Scenario

  1. SomeImages.pbd contains World.png displaying yellow flower
  2. MoreImages.pbd contains World.png displaying blue sky
  3. Window w_Test has picture control containing World.png

Code Sequence

w_test  lw_test1, lw_test2

SetLibraryList("SomeImages.pbd," + GetLibraryList( ) )
Open(lw_test1)

SetLibraryList("MoreImages.pbd," + GetLibraryList( ) )
Open(lw_test2)

Result

I now see two instances of w_test on screen simultaneously. Both display a picture named World.png. However, first window displays a yellow flower while the second window displays blue sky.

So, even though first Open call had the PB VM find World.png in SomeImages.pbd, next Open call instantiating object of exactly same class causes PB VM to find World.png in MoreImages.pbd.

This indicate to me that full library list risks being searched every time PB VM looks for an image. So from performance perspective, PBD files containing images should be as close to front of library list as possible.

HTH /Michael

Comment
  1. Roland Smith
  2. Saturday, 22 June 2019 02:31 AM UTC
The app I work on has all the images compiled into the exe and all libraries generate a PBD. Therefore the exe just contains the generic app start code that all exes have and the images. The application object loads from the PBD.
  1. Helpful
  1. Michael Kramer
  2. Saturday, 22 June 2019 02:46 AM UTC
Good point, thx!

I usually have all code in PBD files like you to minimize EXE size. All images in the EXE puts them right in front of library list which is optimal performance.

I try to minimize EXE using separate resources.pbd containing all images. I will make a point of always placing it at start of library list.
  1. Helpful
There are no comments made yet.
Michael Kramer Accepted Answer Pending Moderation
  1. Wednesday, 22 May 2019 10:55 AM UTC
  2. PowerBuilder
  3. # 1

Thanks, Roland.

The "images in PBD" technique I already use and it works wonders. Chatted with a German developer that saw tremendous speed improvements using this trick and moving the PBD file to front of library list.

I also extracted all my enumeration NVOs into a separate enum.pbl. Each enumeration is an NVO containing only CONSTANT definitions. So all references are solved at compile time. Therefore I can move enum.pbl to end of library list (or even remove it from library list) since compiled code has no references to it.

/Michael

Comment
There are no comments made yet.
Roland Smith Accepted Answer Pending Moderation
  1. Wednesday, 22 May 2019 10:27 AM UTC
  2. PowerBuilder
  3. # 2

My guess would be yes.

There is an easy way to find out. Open a window containing images. Then delete/rename the PBD containing that window & image. If it comes up then you know it was from memory. The runtime only puts file locks on the exe.

 

Here is a interesting idea: You can have an empty PBL in the library list and assign a PBR to it that contains all the images. Once you have compiled the app once, now you can change the library list to use the PBD. Now the exe build process won't have to handle the images.

 

Comment
There are no comments made yet.
  • Page :
  • 1


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