Jump to content

Arrays and memory usage


Dana
 Share

Recommended Posts

I have two sort of related questions. First, some background: My program is primarily a listview for entering and adding up times, along with some other information (an aircraft logbook, if you're interested). There are 16 columns, and columns 6 through 15 are the time columns (there rest are text). In the initial version of the program, I read the previously saved information from a file and created the listview line by line, then calculated the totals by reading back the contents of the listview. This worked fine, but for other reasons I needed to store the time information in an array and use that to make the calculations. The array holds only integer data, maximum four digits per entry. For simplicity (i.e. to keep the numbers consistent) I created a 16 column array (I redim it as each line is added), but I only enter date in columns 6-15 (I leave the other columns in the array blank since I don't need to read them). This also works fine. I could have anywhere from a few dozen to many thousands of lines in the array and listview.

First question: Is it a waste of memory to have a bunch of unused columns in an array as I'm doing? I could use an array only large enough to hold the time data, but then the index numbers wouldn't match the subitem index in the listview... not a big deal, but one more point of confusion while debugging the code.

Second question: It's kind of moot since I need to use the array anyway for other reasons, but if I wasn't, is there any real advantage or disadvantage to storing the data to an array as well as the listview, as opposed to only using the listview and using _GUICtrlListView_GetItemText to retrieve the data when I need to use it?

Edited by Dana
Link to comment
Share on other sites

You might consider an SQLite database as both the storage format and for access/update in the script.

At this point what I have works just fine, and there are other good reasons to want to store the data in a simple delimited text file. Down the road, if there are performance issue, I might consider a change, though more like;y I'd break it up into current and historical files. My questions now are more for a better understanding of the issues.

Link to comment
Share on other sites

Well, it would be a purely performance issue. Even with a couple thousands of rows, your table isn't big enough to use a system-significant amount of memory. I suspect the AutoIt interpreter can read arrays in its own memory space much faster than the calls to WinAPIs can get the data from the ListView's memory space.

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

...I suspect the AutoIt interpreter can read arrays in its own memory space much faster than the calls to WinAPIs can get the data from the ListView's memory space.

Thanks, that's the kind of insight I was looking for. I didn't realize AutoIt went back to Windows API calls to get listview data that it had put there itself (but I didn't dig into the UDF, either).

Link to comment
Share on other sites

Thanks, that's the kind of insight I was looking for. I didn't realize AutoIt went back to Windows API calls to get listview data that it had put there itself (but I didn't dig into the UDF, either).

Don't give me too much credit. I'm not a programmer, and certainly not an AutoIt Dev. That was just a partially-informed opinion. Of course, us common folk always have the option to simply script a test. Do a thousand random reads from and array, and a thousand reads of random ListView items and see how the times compare. My bet is the array reads are much faster.

;)

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...