Jud
-
Content Count
118 -
Joined
-
Last visited
Posts posted by Jud
-
-
It is nothing like Fibonacci. It is a depth-first search on a graph. I'm not trying to make the recursion itself recursive - each time through the loop makes an independent call to the recursive procedure. The instances of the procedure don't have anything to do with each other and there is no global data. That is, I need to make parallel calls to the procedure; the recursion itself is not parallel.
-
I've written several multi-threaded programs with the parallel library, usually using tasks but one or two using parallel for. I have a new one that is more natural for parallel for. The problem is that this is the first one that must use recursion. Inside the loop there is some initial stuff and then it calls a procedure that calls itself, and that isn't working.
If the parallel loop only has one iteration, e.g. parallel.for(1,1 ... ) or parallel.for(2,2 ... ), it works. But for actual work, with the recursion and parallel.for, it locks up.
How can I get a recursive procedure to work in a multi-threaded program?
-
No solution. If I remember correctly, 10.3 didn't have the problem. 10.4 had the problem but then 10.4.1 fixed the problem. But then there were two patches to 10.4.1 that still had the problem. I got 10.4.2 about 3 days ago, and Find Declaration has been working for me. But Refactor/Rename doesn't work (and is worse). Before Refactor/Rename would change the one where you have the cursor, but no others. Now it doesn't even change the one at the cursor.
-
Thanks, I got it.
I read that 10.4.2 retains your old settings. I also read that it requires a complete uninstall, and it defaults to saving your settings. So I did an uninstall first, but it didn't retain my settings.
-
On 2/24/2021 at 11:33 AM, Darian Miller said:Download available from my.embarcadero.com
Where can I download it? I'm a user of 10.4.1 and I had problems downloading the free trial.
-
So "it isn't a bug - it is a feature"? That 2GB limit comes up in other places too. If it is a design choice, they could choose to design it for modern computers.
I remember when Stony Brook Pascal went from 16-bit to 32-bit, there were a lot of places where they forgot to change a 16-bit integer to 32 bits.
-
But that is a limit in Delphi. It could use 64-bit integers and not have that limit. I think this is an oversight in 64-bid Delphi. Dynamic arrays don't have that tiny 2GB limit.
-
Is this 2GB limit a limitation in Windows (even 64-bit)??
-
Thank you. yes, as far as I can tell, the total number of bytes has to be less than 2^31. There are several places where they have not converted to 64-bit integers where they should. Files are bigger now and memories are bigger now.
- 1
-
OK, ELSEIF is NOT an ELSE IFDEF.
-
In Delphi 10.4.1, the following does NOT set Step to 2. Am I missing something?
{$DEFINE test2 }
...
Step := 0;
{$IFDEF test1}
Step := 1;
{$ELSEIF test2}
Step := 2;
{$ENDIF} -
Yes, but it isn't as neat or easy as being able to use tStringList.SaveToFile for its intended purpose. I think it is clear that there is a variable in there somewhere that is to hold the number of bytes and it is an integer instead of an int64.
-
That is a work-around, or using streams with a block size that is small enough to not cause problems.
-
5 minutes ago, emailx45 said:here, I have a file created with your code with 1GBytes of size!
I tryed open in Notepad++ / Wordpad and the app stay for many times and when I clicked it the app crash!
this files very big for open all in one time!
maybe using another software i can open, but I dont have software for this in my pc!
EditPad Pro can open files bigger than 4GB.
-
11 minutes ago, emailx45 said:- In my tests, in 64bits dont occurr any error by EIntOverFlow!
- Only in 32bits, we have the Out Memory because: "strings" -- NOTE: until NOTEPAD++ crash when try open your file-resulted.txt with more than size 1GB with "AAAAAAAAAAAAAAA....."
- I have 16GB RAM and CPU 4x8 i7 4770K and is not enought for open the file, because, the software used try read the file whole on memory... Software like MSWord or similar, do paging to open big-files!
-
System.Classes.pas, line 6815 = SetString(Result, nil, Size); // Out Memory
- as I show in my sample above!
http://docwiki.embarcadero.com/Libraries/Sydney/en/System.SysUtils.EIntOverflow
Did you try in your system?
In my development system I have 32GB and an i7. There are 13 computers here, and their memory ranges from 32GB to 512GB.
Yes, you get the out of memory error in 32-bit mode, which is why I have to use 64-bit mode. The integer overflow occurs in 64-bit mode when using tStrings.SaveToFile method.
The tStringList help page says that tStringList can hold up to 2,147,483,647 strings. But if you have even 1,200,000,000 strings with even one character per sting, you will get the integer overflow error when trying to use the SaveToFile method.
And it isn't because of Windows limit on file size, which is much larger.
-
10 minutes ago, emailx45 said:- In my tests, in 64bits dont occurr any error by EIntOverFlow!
- Only in 32bits, we have the Out Memory because: "strings" -- NOTE: until NOTEPAD++ crash when try open your file-resulted.txt with more than size 1GB with "AAAAAAAAAAAAAAA....."
- I have 16GB RAM and CPU 4x8 i7 4770K and is not enought for open the file, because, the software used try read the file whole on memory... Software like MSWord or similar, do paging to open big-files!
-
System.Classes.pas, line 6815 = SetString(Result, nil, Size); // Out Memory
- as I show in my sample above!
http://docwiki.embarcadero.com/Libraries/Sydney/en/System.SysUtils.EIntOverflow
Did you try in your system?
-
7 hours ago, FPiette said:So everything looks OK no ?
Not for me. I have never gotten the integer overflow error when compiling in 64-bit mode, and this goes back to the first version with 64-bit platform.
-
17 hours ago, Lajos Juhász said:Now back to the original problem. This is the limitation of Delphi strings. You cannot allocate string larger than: (MaxInt - SizeOf(StrRec)) div SizeOf(WideChar) = 1073741815.
Unfortunately, internally TStringList first tries to convert its content to string and using TEncoding to a byte array. That's why it is not suitable to work with large volume of text.
But with the 64-bit platform, why not increase it (use NativeInt). Most computers these days have more than 4GB in them and hard drives 4TB and larger, with large files, are common.
-
17 hours ago, Lajos Juhász said:It's quite easy to test. I've tested using:
procedure TForm1.Button1Click(Sender: TObject); var i: integer; begin i:=1024; while true do i:=i*i; ShowMessage('Completed. The result is:'+i.ToString); end;
When tested using the 64 bit the call stack is:
:00007FF965893E49 ; C:\WINDOWS\System32\KERNELBASE.dll
System._RaiseAtExcept(???,???)
System.SysUtils.ErrorHandler(???,$70AE52)
System.ErrorAt(5,$70AE52)
System._IntOver
mainFRM.TForm1.Button1Click(???)
Vcl.Controls.TControl.Click
Vcl.StdCtrls.TCustomButton.Click
Vcl.StdCtrls.TCustomButton.CNCommand(???)
System.TObject.Dispatch((no value))But it's not bad, double click on the mainFRM.Tform1.Button1Click and the debugger focues where the 32 bit debugger does, so it's just an extra step.
My test case is different, but if I go down to "WriteStringsError.WriteStringsError and click on that, it does take me to the source line after the line that caused the error, so that helps.
-
17 hours ago, David Heffernan said:Is your executable compiled with the overflow checks compiler option enabled?
Yes, it is, and that makes no difference with an integer overflow in 64-bit mode.
-
Just now, David Heffernan said:In what way? Can you be more specific.
As for the main problem, I'm not surprised. I'd expect that you'd be better off using a stream writer to write such a huge collection to a stream. I'd submit a bug report to QP, in case on doesn't already exist, and then write some helper code to workaround the issue.
Are you asking about my pet peeve about 64-bit Delphi not handling integer overflows? It has always had this flaw in the 64-bit version. If you have an integer overflow in the EXE, it just stops, with no error message, If you are running it in the IDE, it doesn't take you to the line the error, as it does in the 32-bit version, and, as far as I know, it does with all other runtime errors. An integer overflow in the 64-bit version in the IDE takes you to the obscure place in my message.
When I have such an error in a 64-bit program, if I can I switch to 32-bit to see where the error is. But many times that is not possible because the 64-bit version has to be used, usually because of memory. And then it usually takes hours and hours to find the source code with the error.
-
I'm getting an integer overflow error when writing more than about 2^30 characters in a tStringList using
SaveToFile in 64-bit Delphi 10.4.1. What I think is happening is that it is using two bytes per character
and this is putting some number over 2^31 and overflowing an integer.Is this one of the things that they haven't made 64-bit yet?
If there are under about 1 billion characters, it works. If there are more, it crashes.
When running the EXE file, it just stops running with no message.
In the IDE, it takes
you to:
procedure _IntOver;
{$IFDEF PUREPASCAL}
begin
ErrorAt(Byte(reIntOverflow), ReturnAddress);
end;in the system unit.
Which brings up another of my pet peeves: 64-bit Delphi has never handled integer overflows properly.
A sample program is attached. -
Yes, but the only documentation I've found about it is: https://github.com/pleriche/FastMM5
I have no idea of how to use it or any of the details of what a memory manager does. I think it should be invisible.
----------
Does anyone know if OmniThreadLibrary will help with this?
-
12 minutes ago, FredS said:I added in my DPR right above madExcept (v5) and it worked fine.
Did you use the NUMA Branch?
I don't know how to do that - I haven't found good documentation on FastMM5. It didn't make a difference on the memory-intensive program on a single-i7 machine.
Recursion in a multi-threaded program
in General Help
Posted
Well, now it is working.