Jump to content

Микола Петрівський

Members
  • Content Count

    69
  • Joined

  • Last visited

Posts posted by Микола Петрівський


  1. 6 minutes ago, A.M. Hoornweg said:

    In the debugger I can break the program, but the current IP is always somewhere inside a Windows DLL and the call stack has no entries.  I tried to make a reproducible test app, but no luck.

    Do not forget, that any app nowadays has multiple threads, and when you break the program, currently selected thread does not necessarily will be VCL main thread. You need to select correct thread in Threads window.


  2. On 4/21/2019 at 12:24 AM, Dalija Prasnikar said:

    Languages with fully automatic memory management models may have their weaknesses with which you may have to deal from time to time, but generally you can just write code without micromanaging objects memory.

    Interesting observation: Android ART is written in C++ and core of Unity (game engine) is also written in C++. In both cases code with manual memory management is doing all hard work, and garbage collected code (Java and C#) sits on top of it. So authors of this codebases also were perfectly aware of problems related to mixing different memory management models, and have separated them on language borders. Delphi has to be good in both low level stuff and business logic, so it had to switch to simpler memory management model.


  3. Quote

    What are talking about? Uniquestring is about COW on top of ARC! Nothing to do with ARC itself. Where I suggested to make instances COW capable? Think!

    If  ARC pointer to instance is to be passed as var parameter, it's just passed without anything.

    
    procedure Modify(var instance:auto TObject);// auto here is mandatory to accept ref_counted instances
    begin
    	instance := auto TObject.Create();//instance is replaced, _Release is called, then ctor!
        // _Release with do NOTHING if FRefCount is NEGATIVE!
    end;
    
    procedure Test();
    begin
    	var inst := auto TObject.Create();
        Modify(inst);//just pass without any fuss
        var classic = TObject.Create;// Non refcount, FREFCOUNT := -1000
        Modify(classic);//just pass without any fuss
    end;

    Your code contains memory leak. After a call to "Modify", pointer to original object, inside "classic" variable, will be lost.


  4. 6 hours ago, AlekXL said:

    typed string constants do have tstrrec structure, their values can be stored in string variables without copying its value, and magic functions to addref and release are called on them, with no effect. So they live in the world of arc without their lifetime being affected by this.

    That's how non refcounted instances should live

     

    what's refcount value of instance pointed by bar, after this assignment, in your opinion?  

    No matter what you do, sooner or later RTL will have to insert a call to UniqueString. For example when you pass your variable to a function with var parameter. For strings this is not a problem, because they are value types, their copying does not have side effects. For objects you can't guarantee, that copying is safe. You can ask programmers to mark their objects as copy safe, and add additional compiler restrictions for unsafe objects. But how many times some object will happen to have wrong mark, and how easy it will be to debug and fix it?


  5. 10 hours ago, Yaron said:

    I tried doing the pre-calculations in a thread, but it resulted in instability. what I'm doing is resizing graphic elements and I simply can't get TBitmap to work without throwing exceptions in a thread on Android.

    As far, as I know, TBitmap had problems with threads in Tokyo. In Rio it should be fine.


  6. 2 hours ago, Lars Fosdal said:

    Also spotted: Read of address DEADC00B.

    Normally I'd expect to see things like this
    EUseAfterFreeError: Application made attempt to call method of already deleted object: $071EC5A0 OBJECT [TMyClass] 404 bytes.

    It is not so easy to detect, that current AV really is a usage of freed object. Especially if you have multiple DLLs, compiled in different versions of Delphi, or something like that. SafeMM can shed some light even in such situation, but at a cost of big memory leak.


  7. In such situation I usually try other debugging tools and compare results. In my list I have FastMM4 in FullDebugMode and SafeMM: https://stackoverflow.com/questions/1039646/trying-to-locate-safemm-for-delphi The last one is especially useful when you want to see precise line of code with the bug. If nothing helps, then I read this article: https://www.eurekalog.com/help/eurekalog/eaccessviolation.php

    And especially list of mistakes that can cause AV. Usually it is one of them.


  8. 15 hours ago, Rudy Velthuis said:

    It is very hard to find good compilers I like. I can get along with C and C++, but I don't like them.

    I love Delphi, but it certainly needs better optimization (and fewer bugs).

    I like assembler too, because it allows me to do almost everything I want. If I want optimization, it is my responsibility. If I have bugs, it was me (well, or the libraries I use).

    Have you looked in to Free Pascal Compiler? It is open source, so you can tweak output assembler as you like, but in the same time it uses Delphi language, which we all love.


  9. 1 hour ago, Incus J said:

    Thank you everyone for the encouragement and advice.  I've made an initial attempt using the TThread class as a starting point - with some success, in that the Cancel button now works.

     

    To verify the main thread remains responsive I placed a spinning TAniIndicator on the form.  It does spin during the lengthy image processing, however it pauses intermittently a couple of times during the processing of each image, which suggests something is still blocking the main thread?

     

    Question:  Apart from updating the UI, is there anything else that typically requires a Synchronize?  For example my thread contains file operations - should they be Synchronized too?

    You should use Synchronize as little as possible, because you are not using threads, when Synchronize is running. Usually you need it only for UI.


  10. 7 hours ago, Tommi Prami said:

    As stated above, using other Dpi than 100% is not good. Because it'll affect into Dfm-files. And you just can't know is there true changes between two, if edited with environments with different Dpi. 

     

    If Delphi woulöd normalize the dfm into 100% font sizes, and Form editor would be totally Dpi agnostic, at design time, it would be way easier to work in a team with different Dpi environments

    RAD Studio works like that since Berlin, probably. But on HiDPI screens everything is very small.

    And do not mix real Screen DPI and Windows Screen DPI, these two values do not have to be the same.


  11. 3 minutes ago, Tom F said:

    If I upgrade in place from Sierra to Mojave, does XCode 9.x.x remain installed on the machine?  Do I have to uninstall more recent XCodes, or can different versions co-exist?  

    It appears that I can download XCode 9.x.x. from here: https://developer.apple.com/download/more/. Is the installation of that download straight-forward to a newcomer?

    XCodes can coexist, but only one of them will be default. RAD Studio uses default XCode to get SDK. I usually just rename nondefault XCodes to something like "XCode 1010.app", and default remains "XCode.app". Installation of new XCode via AppStore usually replaces current default one. But if you download archive, then you can choose what to do.

    • Thanks 1

  12. 14 hours ago, Tom F said:

    I know there are no guarantees, but should I expect RAD Studio 10.2.3 work with the Mojave (and XCode 9.2 that it installs?)  Perhaps I'll just have to redeploy the PAServer?

    Tokyo can compile apps for Mojave, but you have to use XCode 9.X.X, because different versions of XCode have different versions of SDK. And Tokyo does not work with fresh SDK, at least not out of the box. Also, debugger on Mojave does not work. 10.3 Rio can work with any existing version of XCode, but also has troubles with debugger. You have to launch app without debugger, and then attach to running app.

×