April 20, 2024, 07:37:41 AM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


How to determine if more memory is needed?

Started by billhsln, February 15, 2013, 03:01:31 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

billhsln

I am working on a program, which I don't think is too big, but does not work correctly.  I am thinking that I actually run out of memory for my variables.  Is there some way to tell how much is being used and whether I need to increase the amount I have allocated?

DEF iFile, oFile:FILE
DEF prod[6,850]:ISTRING
DEF ucost[850], hucost:FLOAT
DEF csv, f[20], filename, filtercsv, filtertxt, hstmt, sdir, stmt, txt, fp1:STRING
DEF c, fnd[850], t:CHAR
DEF stdoz[850], qoh[850]:INT
DEF f180 = 0, fswhs = 0, kmax = 9:INT
DEF i, j, pFlds[20], nprod,  hstdoz, hqoh:INT


The above is what I have defined and I use AUTODEFINE "off".  Current default is 32K.

Thanks,
Bill
When all else fails, get a bigger hammer.

LarryMc

If that is all your variables you shouldn't be running out.

The 32K number you mentioned in the space allowed for all the variables in any given subroutine.
The other memory number in the Advanced tab is the amout of memory available for all subroutines (nested).

If you were exceeding the 32K number the compiler would give you a warning telling you how much you were using.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

billhsln

I did have one program with DEF stmt[1200]:STRING and it did not complain.  I ended up giving it lots more memory and got it to work.

Bill
When all else fails, get a bigger hammer.

LarryMc

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

billhsln

When all else fails, get a bigger hammer.

LarryMc

Can't offer anything else unless you provide more information or code to look at.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

billhsln

Here is my code.  I ended up using prod180[6:1200]:ISTRING, which saved lots of memory.

Bill
When all else fails, get a bigger hammer.

LarryMc

I'm assuming that prod180[6:1200]:ISTRING was a typo and you meant prod180[6,1200]:ISTRING

I guess I won't be able to help you other than to make the following comments since I don't know assembly and don't have any data.

In the split declaration the last parameter is defined as a pointer

when you call split you are passing it pFlds which you defined as an INT array with 40 elements
so, you are not passing a valid point to the function
I'm thinking it should be more like
j = Split(stmt,t,&pFlds)
But what is really blowing my mind is
f[i] = *<STRING>(pFlds[i])
You are trying to take an element of an INT array and treat it like a pointer and you are saying it's contents is a STRING to be assigned to an element of the string array, F.

And like I said I don't know assembly but I'm not seeing where any memory is being allocated othe than in the definition of the INT array.

Maybe some of the other guys can be more helpful.
Sorry
Either your programming knowledge is way above mine or your aren't close.
And I say it could be 50/50 either way.
LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library

billhsln

The SPLIT function was written by some one else, right off hand I don't remember who.  But the example that I used followed the same scheme I am using.  The function should work, as long as I don't have more tabs or comma's (depending on which delimiter I am passing), then are in the file.  I allow for 40, but there should actually be at most 10.  The SPLIT function works extremely well, the only thing I do extra is force an extra delimiter on the end.

I was thinking that just in my Defines, I am running over 32k.

DEF iFile, oFile:FILE
DEF prod180[1200]:STRING
DEF fnd180[1200]:CHAR
DEF ucost[1200], hucost:FLOAT
DEF prodswhs[750], prodcage[60], prodsant[40]:STRING
DEF csv, f[40], filename, filtercsv, filtertxt, hstmt, sdir, stmt, txt, fp1, fp2:STRING
DEF c, t:CHAR
DEF stdoz[1200]:INT
DEF qohswhs[750], qohcage[60], qohsant[40]:INT
DEF found, f180 = 0, fswhs = 0, fcage = 0, fsant = 0:INT
DEF i, j, pFlds[40], nprod180,  hstdoz, hqoh, nswhs, ncage, nsant:INT


I think prod180[1200] would take 1200*255=306,000, fnd180[1200] = 1,200 chars, prodswhs, prodcage, prodsant 850*255=216,750, stdoz = 1200*2=2,400, gohswhs, gohcage, gohsant = 850*2=1700, misc strings 50*255=12,750, misc other fields approx 100-200.  All totalling to 541,000 needed in memory.

When I compile with default of 32,768, the compile does not complain.

Or are my numbers wrong for the type of memory I am using?

Thanks,
Bill
When all else fails, get a bigger hammer.

LarryMc

Other than what I said about how you are calling split
and trying to turn a int array into a string I don't see anything wrong.
and the 32K is how much memory you have for use INSIDE the subs so I don't see it as a problem

LarryMc
Larry McCaughn :)
Author of IWB+, Custom Button Designer library, Custom Chart Designer library, Snippet Manager, IWGrid control library, LM_Image control library