Re: [fpc-pascal] GetMem slow in threads

2024-11-09 Thread Marco van de Voort via fpc-pascal
Op 9-11-2024 om 14:59 schreef Hairy Pixels via fpc-pascal: The solution would be to be to use a different allocator but because FPC only allows overriding NewInstance per class it would be mean you would need a mutex anyway to control which allocator was used depending on the thread. Maybe

[fpc-pascal] GetMem slow in threads

2024-11-09 Thread Hairy Pixels via fpc-pascal
I diagnosed a threading performance problem down to merely calling GetMem. I did a test and it was 4x slower to call GetMem on 8 threads (my computer core count) than one thread. Due the large amount of allocations in the program it was actually slower to multithread the task. I assume the problem

Re: [fpc-pascal] getmem

2011-05-26 Thread Luis Fernando Del Aguila Mejía
Thanks. El 26/05/2011 06:15 a.m., Felipe Monteiro de Carvalho escribió: On Wed, May 25, 2011 at 7:58 PM, Luis Fernando Del Aguila Mejía wrote: a: = $ ABFE5689 / / Little endian $ 8956FEAB, it is ok Writeln (Hi (a)) / / Show $ ABFE, it is ok Writeln (Lo (a)) / / Show $ 5689, it is ok In a Bi

Re: [fpc-pascal] getmem

2011-05-26 Thread Luis Fernando Del Aguila Mejía
El 26/05/2011 06:15 a.m., Felipe Monteiro de Carvalho escribió: thanks On Wed, May 25, 2011 at 7:58 PM, Luis Fernando Del Aguila Mejía wrote: a: = $ ABFE5689 / / Little endian $ 8956FEAB, it is ok Writeln (Hi (a)) / / Show $ ABFE, it is ok Writeln (Lo (a)) / / Show $ 5689, it is ok In a Bi

Re: [fpc-pascal] getmem

2011-05-26 Thread Felipe Monteiro de Carvalho
On Wed, May 25, 2011 at 7:58 PM, Luis Fernando Del Aguila Mejía wrote: > a: = $ ABFE5689 / / Little endian $ 8956FEAB, it is ok > Writeln (Hi (a)) / / Show $ ABFE, it is ok > Writeln (Lo (a)) / / Show $ 5689, it is ok > > In a Big Endian computer. What shows Hi and Lo? They show same. Language c

Re: [fpc-pascal] getmem

2011-05-25 Thread Luis Fernando Del Aguila Mejía
El 25/05/2011 01:35 a.m., fpc-pascal-requ...@lists.freepascal.org escribió: Question out of curiosity: Is there a reason why you allocate an array "by hand"? Yes, getmem return NIL, when no more memory is available. SetLength, no return NIL, It is work with Exceptions. My intention was whether

Re: [fpc-pascal] getmem

2011-05-24 Thread Claudio Lo Gaffo
El 24/05/2011 03:57 p.m., Luis Fernando Del Aguila Mejía escribió: I'm surprised this compiles at all. Ok, Does my program does not compile on your computer ? You're mixing up manual allocation of memory on the heap for variables such as arrays with compiler allocation of heap memory for ansi

Re: [fpc-pascal] getmem

2011-05-24 Thread Jonas Maebe
On 24 May 2011, at 20:57, Luis Fernando Del Aguila Mejía wrote: > Yes something like that. I'm trying to emulate something like this: > > VarLCad = array[0..2] of ansistring; > Begin > LCad[0]:='01234'; > LCad[1]:='56789'; > LCad[2]:='1'; > Writeln(LCad[2]); > End. > > But using

Re: [fpc-pascal] getmem

2011-05-24 Thread Sven Barth
On 24.05.2011 17:22, Luis Fernando Del Aguila Mejía wrote: I know that you can use dynamic arrays (array of). Is better. But this does not understand and confuse me. Why to create an array of 3 elements (ANSIString) with GetMem, I have to put a size of 15 bytes (5*3) and not 12 bytes (4*3).? The

Re: [fpc-pascal] getmem

2011-05-24 Thread Luis Fernando Del Aguila Mejía
I'm surprised this compiles at all. Ok, Does my program does not compile on your computer ? You're mixing up manual allocation of memory on the heap for variables such as arrays with compiler allocation of heap memory for ansistrings (which are reference counted and deallocated automatically).

Re: [fpc-pascal] getmem

2011-05-24 Thread Jürgen Hestermann
Luis Fernando Del Aguila Mejía schrieb: Var LCad:^ansiString; AnsiString is already a pointer. LCad is now a pointer to a pointer. That should read Var LCad: AnsiString; getmem(LCad,5*3); //ansistring is a pointer 4 bytes The memory allocation and freeing is done by the compiler automat

Re: [fpc-pascal] getmem

2011-05-24 Thread Howard Page-Clark
On 24/5/11 4:22, Luis Fernando Del Aguila Mejía wrote: I know that you can use dynamic arrays (array of). Is better. But this does not understand and confuse me. Why to create an array of 3 elements (ANSIString) with GetMem, I have to put a size of 15 bytes (5*3) and not 12 bytes (4*3).? The prog

[fpc-pascal] getmem

2011-05-24 Thread Luis Fernando Del Aguila Mejía
I know that you can use dynamic arrays (array of). Is better. But this does not understand and confuse me. Why to create an array of 3 elements (ANSIString) with GetMem, I have to put a size of 15 bytes (5*3) and not 12 bytes (4*3).? The program works with 15 bytes, but do not understand why not

Re: [fpc-pascal] Getmem -> Move -> Freemem

2009-04-26 Thread Marco van de Voort
In our previous episode, Guillermo Mart?nez Jim?nez said: > fSize := aObject^.size; > GetMem (fData, fSize); > Move (aObject^.dat, fData, fSize); > > Both "fData" and "dat" are untyped POINTER but the program returns an > "Segment violation" at the Move procedure. I've checked the pointers >

[fpc-pascal] Getmem -> Move -> Freemem

2009-04-26 Thread Guillermo Martínez Jiménez
Hello. I'm using FPC 2.2.2 on Xubuntu 8.10. I need to reserve dynamic memory to store raw binary data. I tried the next code:  fSize := aObject^.size;  GetMem (fData, fSize);  Move (aObject^.dat, fData, fSize); Both "fData" and "dat" are untyped POINTER but the program returns an "Segment vi

[fpc-pascal] Getmem -> Move -> Freemem

2009-04-26 Thread Guillermo Martínez Jiménez
Hello. I'm using I need to reserve dynamic memory to store raw binary data. I tried the next code: fSize := aObject^.size; GetMem (fData, fSize); Move (aObject^.dat, fData, fSize); Both "fData" and "dat" are untyped POINTER but the program returns an "Segment violation" at the Move procedu

Re: [fpc-pascal] GetMem should use out parameter ?

2007-08-22 Thread mm
Skybuck Flying a écrit : Hello, Does GetMem care about the memory contents of the pointer variable ? If not the parameter should be out instead of var to prevent the following hint message: GetMem( node, sizeof(Tnode) ); Y:\Free Pascal\Units\Technical\TnodeList\version 0.08 port to free p

Re: [fpc-pascal] GetMem should use out parameter ?

2007-08-22 Thread Michael Van Canneyt
On Wed, 22 Aug 2007, Skybuck Flying wrote: > Hello, > > Does GetMem care about the memory contents of the pointer variable ? No. > > If not the parameter should be out instead of var to prevent the following > hint message: > > GetMem( node, sizeof(Tnode) ); > > Y:\Free Pascal\Units\Techn

Re: [fpc-pascal] GetMem should use out parameter ?

2007-08-22 Thread Skybuck Flying
Never mind. I see what the problem is. GetMem is actually a kind of (probably magical) wrapper around a memory manager. The real GetMem is a function which returns a pointer. As I already wrote, in Delphi an out of memory exception is raised. The result value is thus never returned, which i

[fpc-pascal] GetMem should use out parameter ?

2007-08-22 Thread Skybuck Flying
Hello, Does GetMem care about the memory contents of the pointer variable ? If not the parameter should be out instead of var to prevent the following hint message: GetMem( node, sizeof(Tnode) ); Y:\Free Pascal\Units\Technical\TnodeList\version 0.08 port to free pascal\unit_TnodeList_versi

Re: [fpc-pascal] GetMem question

2006-12-01 Thread Flávio Etrusco
() var lList : PPropList; begin lList := nil; // <<== New line, I expect to fix a FPC warning ... GetMem(lList, lSize); But it's created a warning in BDS2006 Variable assigned to LList never used - Simply put: the parameter is always di

Re: [fpc-pascal] GetMem question

2006-12-01 Thread Daniël Mantione
Op Fri, 1 Dec 2006, schreef Graeme Geldenhuys: > I got this question from a Delphi 2006 user regarding a code change I > made in the tiOPF project. tiOPF is compiled with FPC using the > Delphi compiler mode. FPC 2.0.4 and FPC 2.1.1 is used. > > - >

[fpc-pascal] GetMem question

2006-11-30 Thread Graeme Geldenhuys
I got this question from a Delphi 2006 user regarding a code change I made in the tiOPF project. tiOPF is compiled with FPC using the Delphi compiler mode. FPC 2.0.4 and FPC 2.1.1 is used. - procedure tiGetPropertyNames(AClass : TtiBaseObjectClass;

Re: [fpc-pascal]GetMem crazy problem

2003-06-11 Thread Jonas Maebe
On dinsdag, jun 10, 2003, at 23:20 Europe/Brussels, Eduardo Morras wrote: I just looked at this again. If you are really getting RTE 201 then it (probably) has nothing to do with the GetMem's. It means you are over-indexing your arrays or seomthing similar. Good luck. That's what surprise me,

Re: [fpc-pascal]GetMem crazy problem

2003-06-10 Thread Eduardo Morras
At 14:22 10/06/2003 -0700, you wrote: Is 1.0.8 available? I just checked www.freepascal.org and it seems like 1.06 is the current release. You might try that version and see if the problem goes away. -Alan 1.07 and 1.08 are updates to 1.06. You must download them and install by hand. In a few

Re: [fpc-pascal]GetMem crazy problem

2003-06-10 Thread Alan Mead
--- Eduardo Morras <[EMAIL PROTECTED]> wrote: > At 12:46 10/06/2003 -0700, you wrote: > >I just looked at this again. If you are really getting RTE 201 > then > >it (probably) has nothing to do with the GetMem's. It means you > are > >over-indexing your arrays or seomthing similar. Good luck. >

Re: [fpc-pascal]GetMem crazy problem

2003-06-10 Thread Eduardo Morras
At 12:46 10/06/2003 -0700, you wrote: I just looked at this again. If you are really getting RTE 201 then it (probably) has nothing to do with the GetMem's. It means you are over-indexing your arrays or seomthing similar. Good luck. -Alan That's what surprise me, so rechecked and yes, the rte

Re: [fpc-pascal]GetMem crazy problem

2003-06-10 Thread Alan Mead
I just looked at this again. If you are really getting RTE 201 then it (probably) has nothing to do with the GetMem's. It means you are over-indexing your arrays or seomthing similar. Good luck. -Alan --- Alan Mead <[EMAIL PROTECTED]> wrote: > Eduardo, > > I did not follow your example, but ar

Re: [fpc-pascal]GetMem crazy problem

2003-06-10 Thread Alan Mead
Eduardo, I did not follow your example, but are you aware of the "growing heap" behavior of FreePascal and the ReturnNilGrowHeapFails variable? http://www.freepascal.org/docs-html/prog/progsu113.html#x163-1680008.4 Also, I think this ReturnNilGrowHeapFails behavior is broken in 1.0.6 and fixed i

[fpc-pascal]GetMem crazy problem

2003-06-10 Thread Eduardo Morras
Hello: I've got a weird problem with getmem. I have check everything (i think) but i can't get it work. Heaptrc says it's all ok, but when i de-comment the next three lines ( the freemem also ), all fails GetMem(sDicc,sizeof(rtBusqBidimen)); GetMem(ppmv,sizeof(rtMotionVector))