Virtual Pascal

Classic Object Pascal for free

After many small programs I made in VP, Ive tryed to reduce memory usage when working with huge arrays of ansistring/records.
I see resizable arrays like x:array of sometype; are not accepted.
Is it a workaround or sadly I must migrate all to Free Pascal ?

I see here people updating VP sources. Can my problem be solved by some update/patch ?

I think it will be usefull to keep a list with updates/mods in a separate discussion as soon as they are tested/approved by Allen.
If not enough space, I offer myself to host the files on my site if the owners send them to me by mail and instruct me what to write as their comments/howTo if necessary on the page.
I can host also entire remaked builds/betas of VP with your contribution.
I like too much VP to see it dead, so if I can't help with knowledge(I dont have much) I can help with hosting.

Please tell me how to help the comunity.
Please tell me how to improve my VP.

Views: 486

Reply to This

Replies to This Discussion

Thank you very much Stefan !
I will try to use/test this soon, after I get rid of the actual emergency, wich kills me.
For now, I've increased the hardware capabilities and working with smaller pieces one time. Temporary emergency sollution.

I have some questions about: TByteArray = array[0..512*1024*1024 div sizeof(Byte)] of Byte.
The available item number is limited to 512Mb of RAM ?
Can this be increased closer to max. RAM available ?
In rares situations that may occur, when loaded items for many "dyn arrays" get total size bigger than available phisical RAM, VP uses swapfile to hold the items ?

Don't know exactly but I think "Count * sizeof(Type)" works only with fixed size types.
Can this work with ansistrings or other "dyn arrays" as elements type ? GREAT, if yes !

ASAP I will try to see if I can make functions to emulate "dyn arrays" behaviour with similar declarations as FP, but now, I can't even make use if I had a direct VP fix.
I just sleep 2-3 hours/day as I delayed too much starting the job, hoping for quick fixed/dynamic modifications in my sources. Now, even 2-3 aditional lines around the fixed arrays assignations are not possible because of remaining time.

I will come back soon.
I hope to see this in a fix for VP, maybe...!

All the best for all of you.
Good morning Portos.

Of course you can increase this.
But I think increasing this > 2GB is critical in VP because of signed and unsigned handling problems.
2GB should be more than enough.

BUT: his type declarataion is "virtual", as it just makes the compiler allow you to index a big
amount of elements in the array. It doesn't matter if you have 10 or 100000 elements.
The actual amount of memory used is up to you by using GetMem() or SetLength().

VP does not provide swapfile handling.
Again, it is up to you to handle and limit the amount of memory your program uses.
I have never worked with swapfiles, so I cannot help you with that.

Yes, Count * sizeof(Type) only works with fixed size types.
But I have ´just checked it: sizeof(AnsiString) = 4.
So, you can have a maximum array of (2GB / 4) AnsiStrings = 536 million.

I have modified the sources from my last post once more to show the possibilities and uploaded
it with this post (I hope it works).

Just a few notes to some lines:
type
TestType = Byte;
PTestArray = ^TTestArray;
TTestArray = array[0..0] of TestType;

Note that this array actually contains only ONE element.

writeln(SizeOf(TestType),' ', sizeof(TTestArray));
The output is "1 1", and would be "4 4" with AnsiStrings.

Last but not least we want to work with this array:
I := $10;
1) P^[0] := 0;
2) P^[1] := 0;
3) P^[I] := 0;

Line 1) is ok, since there's only one element = Index 0
Line 2) will be rejected by the compiler, because the Index is > 0
Line 3) is ok again, since the compiler cannot (fortunately) check the value of I

As you can see the length or size of the "virtual" array type is not important.
It only helps the compiler when indexing into the array.

Sorry for not posting this earlier.

Good luck with your job anyway,
Stefan / AH
Attachments:
(I have no time to quickly check this, but since not allocated with NEW, ref counted types might not be properly initialized. It is probably advisable to fillchar the arrays before using, and call finalize on all elements before deallocating)

RSS

© 2018   Created by Allan Mertner.   Powered by

Report an Issue  |  Terms of Service