heap

Beta Testing discussion on mikroPascal PRO for PIC32.
Post Reply
Author
Message
jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

heap

#1 Post by jpc » 03 Feb 2011 00:09

it looks like the help on the memory manager is not converted from C to pascal, function-names are different (in fact i see no advantage in different names ) and it looks to me the constant heap_size is set in the project-settings already.
Last edited by jpc on 04 Feb 2011 12:31, edited 1 time in total.
Au royaume des aveugles, les borgnes sont rois.

User avatar
srdjan
mikroElektronika team
Posts: 1552
Joined: 28 Dec 2005 12:47
Location: Serbia

Re: heapsize

#2 Post by srdjan » 03 Feb 2011 12:25

Hi,
jpc wrote:it looks like the help on the memory manager is not converted from C to pascal, function-names are different (in fact i see no advantage in different names )
- Yes, the list of routines was not updated.
I'm also against different names and prototypes as well,
but this is mostly matter of taste.
Some Pascal users would criticize C-like names,
some C users would criticize Pascal like names...
Basic users would certainly have their comments too...

We'll unify this for sure, just to think of a proper method to satisfy all.
jpc wrote:and it looks to me the constant heap_size is set in the project-settings already.
- Heap is not used by default and no space is allocated in the compiler.
If you want to use heap you need to check heap check box in Edit Project window
and set size you want to be allocated for the heap. By default this size is set to 2kB.

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

Re: heapsize

#3 Post by jpc » 03 Feb 2011 15:18

would it be possible to add the generic type pointer ? currently we can only use pointers to typed data or fool the compiler by using dword ( in some places i found longword instead, maybe best is to define both types to be valid). It would also be very usefull if you could implement New and Dispose on top of the basic Malloc end Free functions
Au royaume des aveugles, les borgnes sont rois.

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

Re: heapsize

#4 Post by jpc » 03 Feb 2011 15:38

another question related to dynamic variables, it looks like the minimum allocation is 4 bytes, allthough the help suggests 'WantedSize: size in bytes of the dynamic variable to allocate ' the size of a byte seems to be 4 . It may be good to explain this at least ( maybe alignment issue ?)
Au royaume des aveugles, les borgnes sont rois.

jpc
Posts: 1986
Joined: 22 Apr 2005 17:40
Location: France 87

Re: heap

#5 Post by jpc » 04 Feb 2011 13:56

now that we have dynamic heap i started exploring it and have found some issue's
i started with this minimal program

Code: Select all

program testheap;
type testtype = record
                  field1 : string[20];
                  field2 : byte;
                  field3 : array[5]of real;
                end;

var testdata : ^testtype;
    i        : byte;
    tmp : dword;
begin
  i := sizeof(testtype);
  // getmem(testdata,sizeof(testtype)); // <<<<<<<<<<<< results in  Syntax error: Expected "pointer to longword (R100)" but "pointer to record (testdata)" found
  getmem(tmp,sizeof(testtype));
  testdata := tmp;
  with testdata^ do
  begin
    field1 :=  'test';
    field2 := 123;
    for i := 0 to 4 do
    begin
      field3[i] := 42.42 / i;
    end;

  end;
 // freemem(testdata,sizeof(testtype));  // <<<<<<<<<<<< results in  Syntax error: Expected "pointer to longword (R100)" but "pointer to record (testdata)" found
 tmp := testdata;
 freemem(tmp,sizeof(testtype));
end.
i commented the first problem i encountered.

Another issue is when i look at these pointervariables in the simulator, i would like to have a way to see the value of the variable, not just the pointer to it.
In the above example i would like to see the contents of testdata^ , not just testdata beeing no more than an address just provided by the getmem()
Au royaume des aveugles, les borgnes sont rois.

User avatar
srdjan
mikroElektronika team
Posts: 1552
Joined: 28 Dec 2005 12:47
Location: Serbia

Re: heap

#6 Post by srdjan » 04 Feb 2011 16:00

Hi,
We will obviously have to thoroughly revise this library.
Thank you very much for you feedback.

Post Reply

Return to “mikroPascal PRO for PIC32 Beta Testing”