Jump to content

OldBoy

Members
  • Posts

    2
  • Joined

  • Last visited

Posts posted by OldBoy

  1. Working in a project which based in the Factory Pattern,we wanted to remove the child classes from memory as they were too heavy. I had always read that it seemed to be no way to do it. After trying different ideas, I came out with one that spins around of the use of a queue where the data is a class. For this example I used the ‘LV Object’, just trying to do my code the most generic as possible.

     

    When I launch my factory, the code does the following:

    - Obtains a new one element size queue with a LV Object constant as element data type

    - Loads the child using the factory

    - Enqueues the new child in the queue using the function 'Lossy queue element'.

     

    Obviously, at that moment I had my child in memory, but I discovered that once I released the queue, the child vanished as well from the LV hierarchy, allowing me to load a new child in case I needed, using the factory pattern again. You can find the code attached with the post.

     

    As I said I read some posts saying that is not possible to remove the child classes from memory, but this seems to work and I would like to know your opinion, as not being able to run the class hierarchy chart when I run compiled code I cannot ensure that this solution behaves as it seems, although it doesn’t create any errors either.

     

    Thanks for your help and time

     

    P.S I attach a video where you can see the behaviour of the example

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.