Jump to content

Leaderboard


Popular Content

Showing content with the highest reputation on 01/31/20 in all areas

  1. Arnaud Bouchez

    Reading large UTF8 encoded file in chunks

    @Vandrovnik I guess you didn't understand what I wrote. I proposed to read the files in a buffer (typically 2MB-32MB), chunk by chunk, searching for the line feeds in it. It will work, very efficiently, for any size of input files - even TB. Last trick: under Windows, check the FILE_FLAG_SEQUENTIAL_SCAN option when you open such a huge file. It bypasses the OS cache, so make it more efficient in your case. See the corresponding function in SynCommons.pas : /// overloaded function optimized for one pass file reading // - will use e.g. the FILE_FLAG_SEQUENTIAL_SCAN flag under Windows, as stated // by http://blogs.msdn.com/b/oldnewthing/archive/2012/01/20/10258690.aspx // - under XP, we observed ERROR_NO_SYSTEM_RESOURCES problems with FileRead() // bigger than 32MB // - under POSIX, calls plain FileOpen(FileName,fmOpenRead or fmShareDenyNone) // - is used e.g. by StringFromFile() and TSynMemoryStreamMapped.Create() function FileOpenSequentialRead(const FileName: string): Integer; begin {$ifdef MSWINDOWS} result := CreateFile(pointer(FileName),GENERIC_READ, FILE_SHARE_READ or FILE_SHARE_WRITE,nil, // same as fmShareDenyNone OPEN_EXISTING,FILE_FLAG_SEQUENTIAL_SCAN,0); {$else} result := FileOpen(FileName,fmOpenRead or fmShareDenyNone); {$endif MSWINDOWS} end;
  2. Kryvich

    Delphi 10.3.3 - Indy from 0ba2688b Git "Hello World"

    I think I know why you get the exception. Put this code to the FormCloseQuery: if IdTCPServer1.Active then begin IdTCPServer1.Active := False; IdTCPClient1.Disconnect; end; You'll get the exception. Then swap the lines: IdTCPClient1.Disconnect; IdTCPServer1.Active := False; No exception.
  3. dummzeuch

    Memory Management with many objects

    If switching to 64 bits is not feasible, you could try to enable IMAGE_FILE_LARGE_ADDRESS_AWARE which might solve the issue for now. (no idea where this formatting comes from, apparently I can't turn it off)
  4. Lars Fosdal

    How to use the FireDAC Monitor classes

    How to do FireDAC monitoring or logging to file. Here is a rough outline of what you need to do. The code is not ready to use as is and serves only to give you the general gist. Add FireDAC.Moni.Base, FireDAC.Moni.RemoteClient, FireDAC.Moni.FlatFile to your uses clause Somewhere appropriate, create the following - I keep them in my DatabasePool class. FTracing: Boolean // init to False FMonitorBy: TFDMonitorBy; // init to mbRemote FMonitorLink: TFDMoniClientLinkBase; // init to nil // Here is where the actual establishing of the tracing happens depending on the trace model. procedure TDBPool.SetMonitorBy(const Value: TFDMonitorBy); begin Lock; try if (FMonitorBy <> Value) and Assigned(MonitorLink) then FreeAndNil(FMonitorLink); FMonitorBy := Value; // mbNone or mbCustom disables the monitoring if MonitorBy = mbRemote then begin MonitorLink := TFDMoniRemoteClientLink.Create(nil); end else if MonitorBy = mbFlatFile then begin MonitorLink := TFDMoniFlatFileClientLink.Create(nil); TFDMoniFlatFileClientLink(MonitorLink).FileName := ParamStr(0)+'.'+FormatDateTime('yyyymmdd-hhnnss', Now)+'.FireDAC.log'; TFDMoniFlatFileClientLink(MonitorLink).FileAppend := False; end; if Assigned(MonitorLink) then MonitorLink.Tracing := Self.Tracing; finally Unlock; end; end; // Use Tracing to enable / disable the tracing function TDBPool.GetTracing: Boolean; begin Result := FTracing; end; procedure TDBPool.SetTracing(const Value: Boolean); begin FTracing := Value; if not Assigned(MonitorLink) then SetMonitorBy(FMonitorBy) else MonitorLink.Tracing := Self.Tracing; end; procedure TDBPool.SetMonitorLink( const Value: TFDMoniClientLinkBase); begin FMonitorLink := Value; end; // When the DB connection is created - it should assign the MonitorBy value procedure TDB_FD.CreateFireDACConnections; const OSAuthent = 'No'; begin if not Assigned(FConnection) then begin OnConnectionCreate; FConnection := TFDConnection.Create(nil); FConnection.DriverName := DBPool.DataBaseDriverName; // that you have selected - This example assumes an MSSQL driver - see other code block below FConnection.Params.Values[MSSQLParam.Server] := Trim(FHost); FConnection.Params.Values[MSSQLParam.Database] := Trim(FDatabaseName); FConnection.Params.Values[MSSQLParam.OSAuthent] := OSAuthent; FConnection.Params.Values[MSSQLParam.User_Name] := Trim(FUserName); FConnection.Params.Values[MSSQLParam.Password] := Trim(FPassword); FConnection.Params.MonitorBy := DBPool.MonitorBy; ... end; BTW - Selecting the right DatabaseDriverName can have a significant impact on performance. Here is how I currently pick my preferred MSSQL driver. Why are those constants are not in the interface section of FireDAC.Phys.MSSQL, @Dmitry Arefiev? class function TDBPoolMSSQL.FindBestDriver(const Link: TFDPhysMSSQLDriverLink): String; const // Constants copied from implementation section of FireDAC.Phys.MSSQL C_2018_ODBC = 'ODBC DRIVER 18 FOR SQL SERVER'; C_2017_ODBC = 'ODBC DRIVER 17 FOR SQL SERVER'; C_2016_ODBC = 'ODBC DRIVER 13 FOR SQL SERVER'; C_2012_ODBC = 'ODBC DRIVER 11 FOR SQL SERVER'; {$IFDEF POSIX} C_FreeTDS = 'FreeTDS'; {$ENDIF} {$IFDEF MSWINDOWS} C_2012_NC = 'SQL SERVER NATIVE CLIENT 11.0'; {$ENDIF} var DriverList : TStringList; WantedList : TArray<String>; begin Result := ''; // Blank = Default WantedList := {$IFDEF MSWINDOWS} {$IFDEF SQLNative} // defined if supposed to prioritize the old SQLNCLI11 [C_2012_NC, C_2017_ODBC, C_2016_ODBC, C_2012_ODBC] {$ELSE} [C_2018_ODBC, C_2017_ODBC, C_2016_ODBC, C_2012_NC, C_2012_ODBC] {$ENDIF} {$ENDIF} {$IFDEF POSIX} [C_2018_ODBC, C_2017_ODBC, C_2016_ODBC, C_2012_ODBC, C_FreeTDS] {$ENDIF}; DriverList := TStringList.Create; try Link.GetDrivers(DriverList); for var Wanted in WantedList do for var Driver in DriverList do begin // DebugOut('ODBC: "' + Driver + '"'); if CompareText(Wanted , Driver) = 0 then Exit(Wanted); end; finally DriverList.Free; end; end;
  5. Fr0sT.Brutal

    Memory Management with many objects

    I'd recommend to check if such memory consumption is expected. Then you can use FastMM's debug facilities to check allocated items, their exact size, types and many other details.
  6. Dave Nottage

    Linker errors when including Facebook SDK on iOS12

    If you're still having trouble, please look at line 175 here: https://github.com/DelphiWorlds/KastriFree/blob/master/API/DW.iOSapi.Firebase.pas Basically forces the linker to link to libclang_rt.ios.a, which has the "missing" symbol
  7. See here: https://github.com/DelphiWorlds/DeviceLens Thank you DelphiWorlds! This is helping me more than everything else for debugging my Android-Apps
  8. PeterPanettone

    Uses Clause Manager in Tree in r2809

    I have compiled GExperts 1.3.14 build 80 (r2809) in Delphi 10.3.1 : Searched for identifier "newshortcut" in Uses Clause Manager: As you can see in the above screenshot, nothing was found. Then I searched in RFindUnit 1.2.0 and found several identifiers: So why GExperts couldn't find these identifiers? Please have a look at RFindUnit at GitHub - it has a lot of useful features: https://github.com/rfrezino/RFindUnit Unfortunately, the author has abandoned the project. Please ask him whether you can use the source code in the GExperts Uses Clause Manager.
  9. Fr0sT.Brutal

    Uses Clause Manager in Tree in r2809

    @PeterPanettone man you really mixing forum and WhatsApp.
  10. PeterPanettone

    Uses Clause Manager in Tree in r2809

    I couldn't wait, so I implemented the Copy Project Units List myself: The code is very simple: If you like, the button will save the list to a text file instead (in a save dialog), if the CTRL key is pressed while clicking. I have sent you the modified source in a personal message.
  11. PeterPanettone

    Uses Clause Manager in Tree in r2809

    I will do that, but useful ideas from other users could also arise here which could be added to the sf.net ticketing system later.
  12. dummzeuch

    Uses Clause Manager in Tree in r2809

    May I remind you that adding suggestions to the sf.net ticketing system increases your chances of gettimg them implemented?
  13. PeterPanettone

    Uses Clause Manager in Tree in r2809

    If the user has activated the map file usage for UCM (and activated map file creation in the project options) then the list of the project units in UCM contains all units the project uses EXPLICITLY and IMPLICITLY: This list can be quite USEFUL. So please add a button in the Project tab to copy/save this list. This would be very useful!
  14. PeterPanettone

    Uses Clause Manager in Tree in r2809

    BTW, in the UCM configuration options there should be a warning when the user activates the "Read project units from map file rather than .dpr" checkbox (otherwise he would not see any units from the map file): The warning message should say: "Please make sure to activate the Map file creation in the Project options".
  15. PeterPanettone

    Uses Clause Manager in Tree in r2809

    The GExperts UCM has the advantage to open the unit with the selected identifier in the IDE, so the user can inspect it: Unfortunately, RFindUnit does not have this feature. So, in my Christmas wishlist I have inserted a GExperts UCM which has all the other features of RFindUnit.
  16. PeterPanettone

    Uses Clause Manager in Tree in r2809

    Here are the settings: As you can see, the "Parse all units" option is checked. PS: I have also cleared and rebuilt the UCM cache. Still no results for "newshortcut" yet. (However, a search for "newcolor" got 6 results).
  17. dummzeuch

    Uses Clause Manager in Tree in r2809

    By default, the uses manager only looks for identifiers only in the favorite units. If that is empty, you won't get any. In the settings you can tell it to search all units instead.
×