Jump to content

Jacek Laskowski

Members
  • Content Count

    267
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by Jacek Laskowski

  1. Jacek Laskowski

    FastMM5 now released by Pierre le Riche (small background story)

    I can't find a link to the FastMM4Options.inc file. Is FastMM5 no longer a configuration file?
  2. Simple example: program leak; {$APPTYPE CONSOLE} {$R *.res} uses FastMM4, System.SysUtils; type TRx = record s : string; v : Variant; end; TAx = TArray<TRx>; procedure Test; var lA : TAx; begin SetLength(lA, 3); lA[0].s := 'test2'; lA[0].v := 888; lA[1].s := 'test1'; lA[1].v := Now; lA[2].s := 'test3'; lA[2].v := 'str'; end; begin try Test; except on E: Exception do Writeln(E.ClassName, ': ', E.Message); end; end. When I don't assign TDateTime to a Variant field, the debugger shows the array and all records correctly, as in the picture on the left. And there is no leakage. But when I assign TDateTime type to Variant field, as on the right side of the picture, the debugger does not show "plus" in hint window and I get a memory leak at the end. What is wrong with this code?
  3. Jacek Laskowski

    Issue with variant in record in array

    In fact, when I'm not debuging, there is no leak. But is it an IDE error to show the record array (without the record expansion plus) in a hint debugger? Because I was afraid it was a problem in my record and array memory management. I do some tricks there.
  4. How to set the generic class field to the value provided by Variant? The following code is not compiled. ToField<T> = class private fData : T; protected procedure SetFromVariant<T>(const aValue : Variant); [...] procedure ToField<T>.SetFromVariant<T>(const aValue : Variant); var val: TValue; begin val := TValue.FromVariant(aValue); fData := val.AsType<T>; <=== [dcc32 Error] E2008 Incompatible types [dcc32 Error] E2008 Incompatible types
  5. Jacek Laskowski

    Variant to generic T, how?

    @Remy Lebeau I cannot use this constraint because it blocks the use of string types (because it is not a valuable type).
  6. Jacek Laskowski

    Variant to generic T, how?

    @Remy Lebeau That's impossible, fData is generic: [dcc32 Error] E2010 Incompatible types: 'T' and 'Variant'
  7. I got a Chad Z. Hower article: https://www.codeproject.com/Articles/1252175/Fixing-Delphis-Interface-Limitations The author is very critical about the interfaces in Delphi. But he gives examples where he mixes interface and object access, which is doomed to failure in advance. I use interfaces very much, and I don't agree with the statement that there is more trouble with them than good. I don't know e.g. C++ and I don't know how interfaces are solved there, probably my ignorance limits my understanding of the problem. Can someone enlighten me if the interfaces in Delphi are really that badly done?
  8. Jacek Laskowski

    Variant to generic T, how?

    I'm blind, sorry and thx! 🙂
  9. Jacek Laskowski

    Variant to generic T, how?

    Your code is identical to mine, don't I notice anything? I still get compilation error on Delphi 10.3
  10. Jacek Laskowski

    The interfaces in Delphi are bad?

    Very common, basically always, used database classes like TDataset, etc. I create in runtime, they are for example part of business classes, as "Owner" I give them nil. There I would like to use them in the interface model, not in the VCL management model.
  11. Jacek Laskowski

    Do you name your Threads for debugging?

    Unfortunatelly I don't. When it comes to the order of starting the "initialization" section it's not always the same, it all depends on the uses section, in my case your code is launched before RTL/VCL threads. I bypassed this problem by adding a anonymous thread with delay: procedure NameDelphiThreads(const pMainThreadId : THandle); begin TThread.CreateAnonymousThread( procedure var vSnapshot:THandle; vProcessId:THandle; vTE32:TThreadEntry32; i:Integer; begin Sleep(100); vProcessId := GetCurrentProcessId(); vSnapshot := CreateToolhelp32Snapshot(TH32CS_SNAPTHREAD, vProcessId); if vSnapshot <> INVALID_HANDLE_VALUE then begin [...] end; end ).Start; end;
  12. Jacek Laskowski

    The interfaces in Delphi are bad?

    But try this "trick" on TComponent or it's descendants... no way.
  13. Jacek Laskowski

    Do you name your Threads for debugging?

    @Darian Miller Your code starting with initialization is not perfect, because it fires up before all native threads are created.
  14. Jacek Laskowski

    Minifing HTML

    I'm looking for a library/class to minify (compress) HTML files. Is there such a thing?
  15. Jacek Laskowski

    Minifing HTML

    You can: - delete end of lines (CR, CRLF) - delete spaces between fields in css: style="color: white; border: 5px" => style="color:white;border:5px" - delete all spaces and tabs of which there is more than one next to each other (except the <pre></pre> tag) - if the styles are defined within HTML in <style type="text/css"> then all long style names like bold_red_important_text can be replaced by short names
  16. Jacek Laskowski

    ANN HTML Library 4.1 released

    I know that the attribute will not be removed because the library does not know that it is unnecessary. But notice that in the example I gave you, the alt="nothing" attribute appears twice in one tag! This is an example of ugly, junk HTML code that I have to clean up. I would like to do it as automatically as possible, because manual work is very tedious. I imagined that your parser could make it easier for me.
  17. Jacek Laskowski

    ANN HTML Library 4.1 released

    But I mean AUTOMATIC removal of duplicate or unnecessary attributes by library. That's what I'm asking. A library that parses HTML and CSS and creates object-oriented structure (DOM) does it automatically, right?
  18. Jacek Laskowski

    ANN HTML Library 4.1 released

    No, I don't need runtime. But I didn't find a web tool. If you know one, please give me a link.
  19. Jacek Laskowski

    ANN HTML Library 4.1 released

    I have one question, is it possible to optimize HTML and CSS code with your library, i.e. remove unnecessary attributes? For example, I have a code: <img src="logo.jpg" alt="nothing" style="color: white; border: 50px; color: black" alt="nothing" ><div> This tag has an unnecessary attribute alt="nothing" and one of the CSS attributes: "color: white" because both are overwritten. To remove such redundant attributes you would need to parse HTML and CSS (what your library does) and build HTML and CSS from the metadata again. Is this possible in the HTML Library?
  20. Jacek Laskowski

    Minifing HTML

    I need this for html mailing (e-mail in html format)
  21. Jacek Laskowski

    Delphi Rio IDE hangs again and again

    What IDE add-ons/experts do you use?
  22. Jacek Laskowski

    TFDMemTable - how to clear structure?

    This is not a very sophisticated solution 🙂 I was hoping for something better. But... thanks.
  23. Jacek Laskowski

    FireDAC and AV in TFDDatSView.RemRef()

    I have a strange problem with FireDAC (Delphi 10.3.2) I create TFDMemTable dynamically, then I create its structure and index on base key (by memTable.Indexes.Add()). Next, I import data from JSON file (saved previously by TFDQuery object): memTable.LoadFromStream(x, sfJSON); AV is raised in this FD code: procedure TFDDatSView.RemRef; begin FRefs.RemRef; end; And on this import I get access violation in FireDAC code, because internal TFDDatSView field is nil (see attached screenshot)! When I remove the creation of the index there is no error. But I can't do it, because it's part of a big, generic mechanism and it's needed. The index is created when MemTable is in dsInactive mode, can it be the cause? I also noticed that when I do Open/Close this MemTable, there is no error either. What is the cause and how to avoid it without performing spells (like close/open)?
  24. Jacek Laskowski

    FireDAC and AV in TFDDatSView.RemRef()

    OK, the problem is not in FireDAC, but in the code associated with Spring4D. Injected interface for reasons I don't know yet reduces the reference counter to zero and is released, and with it FD objects.
  25. Jacek Laskowski

    MMX for Delphi 10.3 Rio

    Ok, now it's correct, sorry for the false report
×