Watch, Follow, &
Connect with Us
Public Report
Report From: Delphi-BCB/Debugger/Evaluator    [ Add a report in this area ]  
Report #:  7457   Status: Closed
Inspecting large arrays causes the Delphi IDE to hang
Project:  Delphi Build #:  N/A
Version:    10.0 Submitted By:   Vimil Varghese
Report Type:  Crash / Data loss / Total failure Date Reported:  2/28/2004 9:47:16 PM
Severity:    Infrequently encountered problem Last Updated: 3/20/2012 2:24:39 AM
Platform:    All versions Internal Tracking #:   238702
Resolution: Fixed (Resolution Comments) Resolved in Build: : 10.0.2279.20311
Duplicate of:  None
Voting and Rating
Overall Rating: (1 Total Rating)
5.00 out of 5
Total Votes: None
Description
1)create the following types

type
  TIntegerArray=array[0..(maxint)div sizeof(integer)-1] of Integer;
  PIntegerArray=^TIntegerArray;

2) create a variable of type PIntegerArray
3) allocate some memory to it using GetMem
4) assign a value to some element of the array.


#1 procedure TForm1.Button1Click(Sender: TObject);
#2 var
#3  a:PIntegerArray;
#4 begin
#5  GetMem(a,4*sizeof(integer));
#6  a[0]:=3;
#7  form1.caption:=inttostr(a[3]);
#8 end;

5) Place a breakpoint at the line in which the array is accessed ie on line 6

6) Run the application

7) When the breakpoint triggers, Select Evaluate/Modify menuitem from the Run Menu

8) In the expression field type the following
    PIntegerArray(a)^

9) Click on the Inspect button

The Delphi IDE will now hang.

This is because Delphi trys to allocate 2GB
[(maxint)div sizeof(integer) bytes] of data to display all elements of the array.

This is not at all necessary. Even if it were possible to allocate 2GB of memory, our monitor screens are not big enough to display all the 2GB of the data at a time.

Although we would like to see the elements of the array, we do not want to see all the elements of the array at a time.

The Inspector should act like a window into the array, allocating memory for only a small number of elements.

It should show only a specified range of elements of the array,Scrolling should reposition this window so that a different portion of the array becomes visible.  
Steps to Reproduce:
I was able to reproduce this with a 100000 element integer array.  I have attached a test case.  Follow steps 5-8 and click Evaluate (rather than Inspect) and the IDE will crash.

---
[QC Steps]
1)create the following types

type
  TIntegerArray=array[0..(maxint)div sizeof(integer)-1] of Integer;
  PIntegerArray=^TIntegerArray;

2) create a variable of type PIntegerArray
3) allocate some memory to it using GetMem
4) assign a value to some element of the array.


#1 procedure TForm1.Button1Click(Sender: TObject);
#2 var
#3  a:PIntegerArray;
#4 begin
#5  GetMem(a,4*sizeof(integer));
#6  a[0]:=3;
#7  form1.caption:=inttostr(a[3]);
#8 end;


5) Place a breakpoint at the line in which the array is accessed ie on line 6

6) Run the application

7) When the breakpoint triggers, Select Evaluate/Modify menuitem from the Run Menu

8) In the expression field type the following
    PIntegerArray(a)^

9) Click on the Inspect button

The Delphi IDE will now hang.
Workarounds
None
Attachment
None
Comments

None

Server Response from: ETNACODE01