[fpc-pascal] Effective memory allocation

2014-11-02 Thread Xiangrong Fang
Hi All, I am programming a Bloom Filter and need a high-performance way to allocate and wipe large block of memory. I did the following test: program getmem; {$mode objfpc}{$H+} uses epiktimer; const SIZE = 1024 * 1024 * 1024; CNT = 10; var a: array of Byte; p: Pointer; et:

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Xiangrong Fang
Sorry, the results in previous mail was mis-labeled. ​ The result is: Using SetLength: Alloc: 9.40781697E-0001 Clear: 2.13420202E-0001 Using GetMemory: Alloc: 2.8100E-0005 Clear: 7.74975504E-0001 ___

[fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Bee
Hi, Is it possible to do Cocoa GUI programming on Mac/OSX using FreePascal but without objective-pascal mode/dialect? Just pure object pascal or delphi mode. How do I access the Cocoa SDK (foundation, appkit, etc) from pascal code? GUI programming without GUI IDE is fine with me as long as I

Re: [fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Jonas Maebe
On 02/11/14 15:43, Bee wrote: I'm an old pascal lover who feels left alone on Apple platform because FreePascal/Lazarus are no longer Apple friendly like they used to be. How was FPC more Apple friendly in the past than it is now? Jonas ___

Re: [fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Bee
Minggu, 02 November 2014, Jonas Maebe jonas.ma...@elis.ugent.be menulis: On 02/11/14 15:43, Bee wrote: I'm an old pascal lover who feels left alone on Apple platform because FreePascal/Lazarus are no longer Apple friendly like they used to be. How was FPC more Apple friendly in the past

Re: [fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Jonas Maebe
On 02/11/14 16:37, Bee wrote: Minggu, 02 November 2014, Jonas Maebe jonas.ma...@elis.ugent.be mailto:jonas.ma...@elis.ugent.be menulis: On 02/11/14 15:43, Bee wrote: I'm an old pascal lover who feels left alone on Apple platform because FreePascal/Lazarus are no longer

Re: [fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Felipe Monteiro de Carvalho
On Sun, Nov 2, 2014 at 3:43 PM, Bee bee.ogra...@gmail.com wrote: Is it possible to do Cocoa GUI programming on Mac/OSX using FreePascal but without objective-pascal mode/dialect? Just pure object pascal or delphi mode. How do I access the Cocoa SDK (foundation, appkit, etc) from pascal code?

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Sven Barth
Am 02.11.2014 14:55 schrieb Xiangrong Fang xrf...@gmail.com: Hi All, I am programming a Bloom Filter and need a high-performance way to allocate and wipe large block of memory. I did the following test: program getmem; {$mode objfpc}{$H+} uses epiktimer; const SIZE = 1024 * 1024 *

Re: [fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Sven Barth
Am 02.11.2014 15:44 schrieb Bee bee.ogra...@gmail.com: It is also breaks one of the most important advantage of FreePascal: cross platform language. How will you be cross platform if you access Cocoa directly? Regards, Sven ___ fpc-pascal maillist -

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Constantine Yannakopoulos
On Sun, Nov 2, 2014 at 3:54 PM, Xiangrong Fang xrf...@gmail.com wrote: Also, I usually use pointer to pass block of memory to functions. How do I implement a function with the following signature: procedure MyProc(var Buf; Len: Integer): I mean, how to handle var Buf inside the procedure

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Xiangrong Fang
2014-11-03 2:50 GMT+08:00 Sven Barth pascaldra...@googlemail.com: If you use SetLength the dynamic array consists not only of the array data, but also of an information record in front of it. This will likely lead to the data not being aligned correctly (FillQWord works best with 8-Byte

Re: [fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Bee
On Mon, Nov 3, 2014 at 12:28 AM, Jonas Maebe jonas.ma...@elis.ugent.be wrote: I assume you didn't put it there in the hope that nobody would ever notice it or ask questions about it. If you did in fact hope that, then there are probably more effective approaches than posting it to the

Re: [fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Dmitry Boyarintsev
On Sun, Nov 2, 2014 at 10:10 PM, Bee bee.ogra...@gmail.com wrote: Take a look at Delphi. From a single source code base, we can compile it for Windows and Mac. Hardly any changes are required. But if you want to target Mac using FPC, I believe you have to use objective-pascal to access Cocoa

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Sven Barth
On 03.11.2014 02:59, Xiangrong Fang wrote: 2014-11-03 2:50 GMT+08:00 Sven Barth pascaldra...@googlemail.com mailto:pascaldra...@googlemail.com: If you use SetLength the dynamic array consists not only of the array data, but also of an information record in front of it. This will

Re: [fpc-pascal] cocoa programming without objective-pascal mode

2014-11-02 Thread Sven Barth
On 03.11.2014 04:10, Bee wrote: On Mon, Nov 3, 2014 at 1:52 AM, Sven Barth pascaldra...@googlemail.com mailto:pascaldra...@googlemail.com wrote: How will you be cross platform if you access Cocoa directly? Take a look at Delphi. From a single source code base, we can compile it for Windows

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Nikolay Nikolov
On 11/02/2014 03:54 PM, Xiangrong Fang wrote: Hi All, ... Also, I usually use pointer to pass block of memory to functions. How do I implement a function with the following signature: procedure MyProc(var Buf; Len: Integer): I mean, how to handle var Buf inside the procedure body? You

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Nico Erfurth
On 02.11.14 15:05, Xiangrong Fang wrote: Sorry, the results in previous mail was mis-labeled. ​ The result is: Using SetLength: Alloc: 9.40781697E-0001 Clear: 2.13420202E-0001 Using GetMemory: Alloc: 2.8100E-0005 Clear: 7.74975504E-0001

Re: [fpc-pascal] Effective memory allocation

2014-11-02 Thread Xiangrong Fang
2014-11-03 14:39 GMT+08:00 Sven Barth pascaldra...@googlemail.com: Would you mind to show the timings that you got for FillChar? :) ​Using FillChar is always about 5% (or less) faster than FillQWord when used with GetMemory, but will be around 20%-40% faster if the memory is allocated by