Announcement

Collapse
No announcement yet.

Memory Allocation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Memory Allocation

    Hi,
    I've seen some issues on this already, but I'm getting stuck.

    What I'm trying to do is load database tables into memory for speed. I would prefer to put them all in 1 array (so 3 dimensions).
    If I count the maximum values for colcount and rowcount I have to redim the global array : IDX(395,6363,165)

    I believe this is still well within the maximum allowed elements for an array but of course memory is an issue here. I get an error 7. I've tried putting the first dimension on 5 which works, 10 is already a problem.
    I'm having more than enough memory left (~126 MB) so that should do.

    So I tried GlobalAlloc(%GMEM_FIXED, iBytes) where iBytes = 40*1024*1024 so that 40 Mb. The system monitor shows the drop but it still doesn't work.

    How should I handle this?

    Hope someone can help,

    Jeroen Brouwers


    ------------------

  • #2
    Assuming this is just a BYTE array, it is going to take 396 * 6364 * 166 = 418,343,904 bytes to store it, plus a few more for the array descriptor table. If this is LONG integers, then you are looking at around 1.6Gb of virtual memory!!!

    Therefore, it is a safe bet that the Error 7 was because Windows could not allocate enough virtual memory, probably from a lack of disk-space, or your swap file has a size limitation, etc.

    If this is just to load three tables, then maybe you really want a 2 dimensional array? One dimension is the row data, the other is the table number.
    Code:
    ' Pseudocode
    DIM db(%NumDBs, %maxrows) AS <type>
    DataFromDB1 = db(1, rownum)
    DataFromDB2 = db(2, rownum)
    DataFromDB3 = db(3, rownum)
    ------------------
    Lance
    PowerBASIC Support
    mailto:[email protected][email protected]</A>
    Lance
    mailto:[email protected]

    Comment


    • #3
      Ok, you're right, I made a miscalculation. Or to look at it another way: Damned that's gonna be expensive!

      Sincerely
      Jeroen

      ------------------

      Comment

      Working...
      X