login about faq

I am running out of memory in a Logix processor. I have a lot of UDT's that contain more memory than I need, so for example, I am updating the UDT to use SINT instead of DINT for a lot of the elements.

I am also grouping like elements together, as I believe the UDT memory is allocated as DINTS anyway and a new datatype cases a new DINT to be created (internally).

So if I am able to decrease the size of my UDT by 100 Bytes, and that UDT is used across 200 tags, why doesn't my overall memory usage decrease by 20K?

asked Sep 08 '10 at 13:17

Jeremy%20Sluyters's gravatar image

Jeremy Sluyters ♦♦
419213

edited Oct 29 '10 at 15:37

Can you post your before and after UDTs?

(Sep 10 '10 at 19:28) Scott Whitlock ♦♦

The above is correct for single tags; however a udt is layed out in 32 bit boundries so if you have a DINT then 4 SINT it will take 8 bytes. If you have a SINT then a DINT the first SINT will take 4 bytes and the dint will take 4 bytes again using 8 bytes. So starting at the top of your UDT think in 32 bit boundries. You can see this by playing around and looking at the UDT size. Again you could declare 8 bools a sint and 1 int and it would fit into the 32bit boundry. If layed out correctly using bools and sints can save space in a UDT.

link

answered Jan 18 '11 at 23:26

Ryan%20Webber's gravatar image

Ryan Webber
111

The memory is organized by DINT. So even if you delcare SINT it will use a DINT so now you have used 8 + 16 instead of 16. So try to never use SINT unless no other option. Change all your SINT to DINT.

Second, it also groups BOOL into DINT. You need to place all of your BOOLs together so it can build them into the fewest number of DINT. If you have a single BOOL in the midst of other types it will use an entire DINT for that one BOOL.

So group all of your types together

Also if possible declare your 200 tags as an array of the UDT type instead of individually declaring.

link

answered Jan 10 '11 at 13:03

Chris%20Oxley's gravatar image

Chris Oxley
1

Thanks for you answer, the sints were all grouped into arrays to optimize the space already, and I have optimized all other elements already. I agree that if I had 2 single SINT elements after another, than it would use 2 DINTS. In my case the estimated size of the array decreased dramatically (100Bytes) when I changed from DINTS to SINTS, but it did not free up any processor memory. Is the estimated memory size just out of whack?

(Jan 10 '11 at 21:16) Jeremy Sluyters ♦♦

If you already grouped DINTs then SINTs then BOOLs consecutive and still in hunger for more, try running a export to L5K and then importing back to .ACD and see what you get:). This will do like some kind of hdd defragmentation, especially if you created tags online. Another way which I don't know if can apply here is to create smaller UDT's in UDT and maybe you can assign a tag as a smaller UDT type (if you don't need all members for all tags). This depends of application. Good luck!

link

answered Feb 14 '11 at 19:13

ivirban's gravatar image

ivirban
1

Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or __italic__
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×9
×3

Asked: Sep 08 '10 at 13:17

Seen: 1,286 times

Last updated: Feb 14 '11 at 19:13