crash with GetMemPages() failed in single user
Aldevinas Katkus
12-27-22
Operating system: Windows
I am importing/updating 7000+ Contacts (CUVc) from a tab separated file. Import crashes with Failed to allocate virtual memory, GetMemPages() failed, sometimes without any message.
I splitted contacts file to smaller, 2K contacts only. The first file imported fine, then immediately the second one crashed. After restarting the exe the same second file imported successfully. I suspect memory leaks.
If I try to put a few lines into the test file before and after the line which caused the crash, everything is fine.
Can RecordNew() or smth else leave memory leaks in single user mode while it does not in client server mode?


GetCustomer2() is being used elsewhwere every day for half a year without problems, but max number of calls in a loop can be tens, not thousands.
Crash happens in 2021-04-18 and 2022-11-25 versions.

Code:
while (NextImportLine(false)) begin
RecordClear(tCUr);//clear temporary record
RecordClear(Mailr);//workaround for crash with 7K+ lines


tCUr.Comment2 = ImportField;
....
if (testf) then begin
tstr = StripNonDigits(tCUr.RegNr1);
if ((nonblank(tstr)) and (nonblank(tCUr.Name))) then begin
LogText(0,"GetCustomer2 " & tstr & " " & tCUr.Name);
custok = GetCustomer2(tstr,tCUr.Name,"",0,CUr,Mailr,problemf,false);//crash here
end;
...
end;

GetCustomer2() returns a new or existing CUVc if found one:
global
updating function boolean GetCustomer2(string code,string name,string newcustcat,integer logtype,var record CUVc CUr,var record MailVc Mailr,var boolean problemf,boolean useaddresslookup)

begin
...
RecordClear(CUr);

CUr.RegNr1 = code;
if ReadFirstKey("RegNr1",CUr,1,true) then begin
cufoundf = true;
end else begin
CUr.Name = name;
if ReadFirstKey("Name",CUr,1,true) then begin
cufoundf = true;

end;
end;
if (cufoundf) then begin
res = true;
end;

if (!cufoundf) then begin
if (NameIsCompany(name)) then begin
RecordNew(CUr);
....
if (RecordInsert(CUr,false)) then begin
res = true;
...
Aldevinas Katkus
12-28-22
I made a repeatable crash case (Windows 10, single user mode). This import crashes when I run it 4th time in a row in 2021-04-18 version and 3rd time in 2022-11-25 version. In 2022-11-25 version the import is also much slower than the older version.

Line 7489 is the last line in the file. First 2-3 runs everything is OK, then it crashes.

2022-12-28 11:57:26 AD SomeFunction call. Line 7489
2022-12-28 11:57:26 AD runtime error, hal stack is:Stack empty
2022-12-28 11:57:26 AD dump of call stack


updating function boolean SomeFunction(var record CUVc CUr)
begin
RecordClear(CUr);

RecordNew(CUr);
SomeFunction = true;
return;
end;

global
updating procedure ImportTestIn(record RcVc RepSpec)
begin
string 255 tstr;
record NotepadVc Noter;
record MailVc Mailr;
record CUVc CUr,oldCUr,tCUr;
longint LineNr;

LineNr = 0;
while (NextImportLine(false)) begin
LineNr = LineNr + 1;
RecordClear(Mailr);
RecordClear(tCUr);

if (SomeFunction(CUr)) then begin
LogText(0,"SomeFunction call. Line " & LineNr);
RecordCopy(oldCUr,CUr);
end else begin
end;
end;

return;
end;
Leave Comment
You can subscribe to notifications for this post by selecting the 'star' icon on the top right corner of the post.
Back to the list
Latest Posts
Reino Botha
Please check your version of android if it is the same as the server you are connecting too. ...
08:24 21 Nov 2024
Bror-Erik Kotiranta
In NC you hace operations>>ai chats. They are used for these Br, Bror-Erik...
05:12 21 Nov 2024