Shop OBEX P1 Docs P2 Docs Learn Events
memory use — Parallax Forums

memory use

Speaker337Speaker337 Posts: 14
edited 2011-02-06 02:58 in Propeller 1
New to the propeller. If I have several objects that all are instances of FullDuplexSerial does FullDuplexSerial get loaded several times or just once? If I only use two methods, is it worth renaming it and stripping out all the methods that are not going to be used?

Comments

  • kuronekokuroneko Posts: 3,623
    edited 2011-02-05 20:18
    Each object is only included once. However, their VAR sections are unique (one each). As for method removal, yes, possible but most of the time hardly worth it. You could have a look at bst & Co which have the option of removing unused code.
  • MagIO2MagIO2 Posts: 2,243
    edited 2011-02-06 02:58
    Just want to set the wording staight:

    MyObj.spin:
    obj
      fd: "FullDuplexSerial"
    ....
    

    MyObj is instanciating FullDuplexSerial. fd is an instance of FullDuplexSerial.

    So, with this common definition you question makes no sense, but kuroneko seems to be understanding what you meant.

    With the propeller tool it does no make sense to remove function A of FDS in one module and function B of FDS in another module because these are not used there. The propeller tool will then no longer detect, that the rest of the functions are the same. For example:
    modul1.spin
    obj
      fd: "FullDuplexSerial_Aremoved"
    ...
      ' code here only uses B and C
    
    
    modul2.spin:
    obj
      fd: "FullDuplexSerial_Bremoved"
    ...
      ' code here only uses A and C
    
    main.spin:
    obj
      mod1: "modul1"
      mod2: "modul2"
    ...
    

    Now you have 2 copies of the common code of FullDuplexSerial in your main. Hence, these include PRI functions and DAT sections.
    In this case it would be better to use FullDuplexSerial only. All functions and DAT sections will only be there once. The VAR section is duplicated but that's needed anyway.
Sign In or Register to comment.