Leaderboard
Popular Content
Showing content with the highest reputation on 01/29/25 in Posts
-
I mean, the memory can get paged out again so it's not that terrible. Another issue is that the paging system can't share the memory between processes if it's in memory rather than loaded off disk. I still don't understand what actual problem people who want to make their executables a few mb smaller are trying to solve.
-
The next release of ICS is finished, in SVN and the overnight zip. Once documentation is finished, it will be release next week. Meanwhile, testing of this version would be appreciated, so any serious problems can be found and fixed before the release. I'd particularly like C++ users to try and install it, it's okay for Win32, but getting some missing symbols for Win64, despite adding them. Angus
-
The problem with using UPX is the following. Normally Windows would open an executable file using a "memory mapped file" mechanism instead of bluntly allocating memory and loading the contents. This allows the Windows virtual memory manager to efficiently "page in" sections of the executable as needed (on demand paging), improving performance and minimizing memory use. If the file is compressed using UPX, execution starts in the UPX loader stub which immediately allocates a big block of memory and extracts the executable into that before proceeding with the "real" execution. This simply wastes precious resources.
-
Never do this. It's pointless, defeats stuff the OS does to make accessing data in the file efficient, triggers more false-positives, and provides no real benefits, unless you are dealing with a severe lack of storage on the deployment target, which should be fixed in other ways. You can zip the file for transmission bandwidth savings.
-
Hi the Delphi Praxis community, I'm happy to announce to you that since now the SVGMagic component library is open-source and free for commercial and non-commercial use, under the MIT license. Please find the source code here: https://github.com/Jeanmilost/SVGMagic And the website was migrated here: https://jeanmilost.github.io/svgmagic.web/
-
Generic Command Line Parser for Delphi 10.3.x
Primož Gabrijelčič replied to Lars Fosdal's topic in I made this
My approach: https://github.com/gabr42/GpDelphiUnits/blob/master/src/GpCommandLineParser.pas -
You don't need an owner; Just specify nil as the owner in the constructor and remember that you have to destroy the object in the thread destructor (or on exiting Execute, if you create it there). Generally, the purpose of Owner is to have a TComponent destroyed automatically when the owner is destroyed, which is handy when you place stuff on a form. For dynamically created components it is better to control the lifetime (Create/Destroy) explicitly so you have complete control of what is going on and when. It also makes the code easier to understand when you don't rely on implicit behavior.
-
Yes. It doesn't hurt but if you are not referencing the type then you might as well delete it. I couldn't spot any obvious issues after a brief look through the source. One thing I would do though, is to move the TCommPortDriver.Create into the Execute method so it is constructed in the context of the thread, instead of the calling thread (which is supposedly the main thread).
-
Coming back to the threading; Remember that Thread-Safety is important and you need to be certain that the ComPortDriver does not do thread-UNsafe things.
-
CommPortReceiveData is a method pointer. @CommPortReceiveData is a pointer to a method pointer. You have declared TCommPortReceiveData as a "procedure of object". That makes it a method pointer so this: procedure CommPortReceiveData(Sender: TObject; DataPtr: Pointer; DataSize: Cardinal); is wrong (it's not a method; It's a procedure) while this: procedure TUploadThread.CommPortReceiveData(Sender: TObject; DataPtr: Pointer; DataSize: Cardinal); is correct. You haven't declared the method. You have declared a pointer to a method. Your declaration in TUploadThread should look like this instead: TUploadThread = class(TThread) private ...other stuff... procedure CommPortReceiveData(Sender: TObject; DataPtr: Pointer; DataSize: Cardinal); ...more stuff... end;
-
The CommPortReceiveData member you declared is incorrectly declared and should be somethin like: (Note that the parameters should be the same as CommPortDriver1.OnReceiveData) procedure CommPortReceiveData(Sender: TObject; DataPtr: Pointer; DataSize: Cardinal); This should be a method of the class and in there you will handle the data you received. The way you did is not what you want and is what you would have done if you wanted an Event property to be added tou your class.. like so: private FOnCommDataReceive : TCommDataReceiveEvent public property OnCommDataReceive : TCommDataReceiveEvent read FOnCommDataReceive write FOnCommDataReceive; As a side note; try and use Delphi naming standards. Generally accepted, your class fields should have F prefixed to their names.
-
Is there a program for Converting from VCL to FMX?
limelect replied to JohnLM's topic in Delphi IDE and APIs
It seems you don't read carefully still missing cbAppDataFmx Well I do not presume to be the debugger OK it seems you added the file later But now you use newer Delphi and mine is 10.2.3 so good luck. There are out there even Delphi 5 Stop guys using NEW (above 10) as not everybody has the luxury of buying every year a new Delphi. P.S I have been with Delphi since #1 -
I'd strongly advise against UPX especially in production executables. I had my fair share of after-the-last-moment struggle because of it
-
For point 3, grid : Look in my github https://github.com/Serge-Girard/StringGrid2Clipboard this discussion https://www.developpez.net/forums/d2134806/environnements-developpement/delphi/composants-fmx/desktop-tstringgrid-fmx-selections/ For ListView I wrote many bills in my French Blog look for tag Listview https://www.developpez.net/forums/blogs/138527-sergiomaster/b8177/fmx-selection-delements-tlistview/ Bonus : https://www.developpez.net/forums/blogs/138527-sergiomaster/b8201/fmx-selection-delements-tlistview-bonus/
-
That is most likely because you only use a small part of these packages. When building a monolithic exe the compiler will only take the parts actually used, but the packages contain a lot more.
-
record functions with parameters?
bravesofts replied to Nigel Thomas's topic in Algorithms, Data Structures and Class Design
sorry, i can't understand your question --- are you trying to make more than one property read from single universal function, or you are trying to build a record for converting strings to integers ? --- or are you trying to build a dictionary of integers based on given strings ? this is what i can help for, if i get exactly what you want: if a dictionary: unit API.MyDictionary; interface uses System.SysUtils, System.Generics.Collections; type TDictionaryContainer = TDictionary<string, Integer>; TMyDictionary = class private fStrDictionary: TDictionaryContainer; function GetValueOrDefault(const aKey: string): Integer; procedure Log(const aMessage: string); public constructor Create(const aStrList: array of string); destructor Destroy; override; procedure AddOrUpdateKey(const aKey: string; aValue: Integer); procedure RemoveKey(const aKey: string); function TryGetValue(const aKey: string; out aValue: Integer): Boolean; property Dictionary: TDictionaryContainer read fStrDictionary; property Values[const aKey: string]: Integer read GetValueOrDefault; end; implementation { TMyDictionary } constructor TMyDictionary.Create(const aStrList: array of string); var I: Integer; begin fStrDictionary := TDictionaryContainer.Create; Log('Dictionary created.'); for I := Low(aStrList) to High(aStrList) do begin fStrDictionary.Add(aStrList[I], 0); // Initialize all keys with a default value of 0 Log(Format('Key "%s" added with default value 0.', [aStrList[I]])); end; end; destructor TMyDictionary.Destroy; begin Log('Dictionary destroyed.'); fStrDictionary.Free; inherited; end; procedure TMyDictionary.Log(const aMessage: string); begin // Simple console output for logging. // Replace this with your custom logging if needed. Writeln('[LOG] ', aMessage); end; procedure TMyDictionary.AddOrUpdateKey(const aKey: string; aValue: Integer); begin if fStrDictionary.ContainsKey(aKey) then begin fStrDictionary.AddOrSetValue(aKey, aValue); Log(Format('Key "%s" updated with value %d.', [aKey, aValue])); end else begin fStrDictionary.Add(aKey, aValue); Log(Format('Key "%s" added with value %d.', [aKey, aValue])); end; end; procedure TMyDictionary.RemoveKey(const aKey: string); begin if not fStrDictionary.ContainsKey(aKey) then begin Log(Format('Failed to remove key "%s": Key not found.', [aKey])); raise Exception.CreateFmt('Key "%s" does not exist in the dictionary.', [aKey]); end; fStrDictionary.Remove(aKey); Log(Format('Key "%s" removed.', [aKey])); end; function TMyDictionary.GetValueOrDefault(const aKey: string): Integer; begin if not fStrDictionary.TryGetValue(aKey, Result) then begin Result := 0; // Default value Log(Format('Key "%s" not found. Returning default value %d.', [aKey, Result])); end else Log(Format('Key "%s" found with value %d.', [aKey, Result])); end; function TMyDictionary.TryGetValue(const aKey: string; out aValue: Integer): Boolean; begin Result := fStrDictionary.TryGetValue(aKey, aValue); if Result then Log(Format('Key "%s" found with value %d.', [aKey, aValue])) else Log(Format('Key "%s" not found.', [aKey])); end; end. the dpr console test: program DictionaryPrj; {$APPTYPE CONSOLE} {$R *.res} uses System.SysUtils, API.MyDictionary in 'API\API.MyDictionary.pas'; procedure TestMyDictionary; var MyDict: TMyDictionary; Value: Integer; begin // Create the dictionary with initial keys MyDict := TMyDictionary.Create(['Key1', 'Key2']); try MyDict.AddOrUpdateKey('Key1', 10); MyDict.AddOrUpdateKey('Key3', 15); MyDict.TryGetValue('Key2', Value); MyDict.Values['Key1']; MyDict.Values['Key4']; // Returns default value (0) MyDict.RemoveKey('Key1'); MyDict.AddOrUpdateKey('Key1', 100); MyDict.Dictionary.Items['Key1']; finally MyDict.Free; end; end; begin try TestMyDictionary; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; Readln; end. i hope this what you looking for.. -
If it simply the size of the .exe you are looking to reduce, I use UPX, https://github.com/upx/upx/releases, it handles 32 & 64 bit Apps. I use a compression value of 7 and get a roughly 30% reduction in .exe size. It will also handle wild card file names, i.e. upx -7 *.exe.