Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

runtime error on second programm instance #6

Open
mjmucha opened this issue Jul 27, 2017 · 22 comments
Open

runtime error on second programm instance #6

mjmucha opened this issue Jul 27, 2017 · 22 comments

Comments

@mjmucha
Copy link

mjmucha commented Jul 27, 2017

When starting a second instance of the same program with BrainMM i get a access violation on the line 10523 (master).

  if (BrainMMRegistered.BrainMM.Options.FreePacalCompiler <> {$ifdef FPC}True{$else}False{$endif}) then
    begin
      BrainMMFreeMemOriginal := MemoryManager.Standard.FreeMem;
      MemoryManager.Standard.FreeMem := BrainMMFreeMemInverter;
    end;

It seems that MapAddress := MapViewOfFile(BrainMMRegisteredHandle, FILE_MAP_READ, 0, 0, 0); isn't working as expected (line 10470). The fields of BrainMMRegistered are all nil.

This bug occurs with Debug Win 32 Delphi 10.2 Toyko.

@d-mozulyov
Copy link
Owner

Thanks!
Could you attach a test project please to repeat the bug?

Now the BrainMM is unstable, a development will be continued this autumn (may be winter)

@mjmucha
Copy link
Author

mjmucha commented Jul 27, 2017

Sure!
BrainMM Test.zip

Nice to hear! We are using it now for a 2D OpenGL game which is in development sine ~2012 and got serious performance boosts from it.

@d-mozulyov
Copy link
Owner

Great to hear it :)

@vfbler
Copy link

vfbler commented Aug 14, 2017

Buffer: array[0..SizeOf(BRAINMM_MARKER) + 8] of WideChar;
->
Buffer: array[0..Length(BRAINMM_MARKER) + 8] of WideChar;

@hippowar
Copy link

Wow! it's already reported...
i just did like this.
FillChar(Buffer, SizeOf(Buffer), #1);

@d-mozulyov
Copy link
Owner

Hi!

Unfortunately, the library development was temporarily suspended.
Hope it will be continued this summer!

@chmichael
Copy link

Can't wait, it seems you have made awesome job and a couple bugs stops people from using it. :)

@mjmucha
Copy link
Author

mjmucha commented Mar 25, 2018

We are still using it and we also can't wait for updates! :)

@chmichael
Copy link

Hello,
Any chance this summer ? :)

@d-mozulyov
Copy link
Owner

Hello, guys! I want to say thank you for your anticipation and patience! However, at the moment there are more priority tasks. The next possible release date is winter. Or if someone succeeds in attracting donations/investments of $5000-$10000 - the development will continue immediately. Thank you again for your attention to the project!

@jaclas
Copy link

jaclas commented Jun 5, 2018

Well... I guess so this thread can be now closed, forever ;-)

and please try https://github.com/maximmasiutin/FastMM4-AVX

@chmichael
Copy link

Hello Mozulyov,
Well it's unlikely anyone will donate such amount for project with serious bugs too.
You can setup a "donation" somewhere and everyone who wants will donate.

Another solution is to make it shareware which you definitely make money there especially if it's better than FastMM.

I would glady donate 20$ if the service bug is fixed so i can use it.

@d-mozulyov
Copy link
Owner

jaclas, Thank you for the good link. But FastMM4-AVX still works through locks. This means that on multithreaded applications, BrainMM or even WindowsMM will be much faster. Here is a project-benchmark, you can check the performance yourself.

Advantage of the library in accelerated memory re-allocation operations. But in fact re-allocation of memory is a rare operation. In algorithms where re-allocation is required, the concept of "capacity" is used, when the memory is periodically allocated more than necessary to fill it in the future. Such an approach, for example, is used in containers TList<> and ТDictionary<>. In TMemoryStream/TByteStream. This can be useful for dynamic arrays and strings. But since Delphi 10.1 (Berlin) re-allocation of dynamic arrays is only through the creation of new ones. And strings in the areas critical for the speed are filled through the TStringBuilder (also through capacity).

But the link is really useful. Many thanks!

@chmichael
Copy link

I did "advertise" the project and your needs on Google+ Delphi Developers, i hope i turns well and you can continue the development.

@d-mozulyov
Copy link
Owner

d-mozulyov commented Jun 8, 2018

chmichael, oh, cool, thanks!
Donate Link
USD VISA 4779 6426 1574 7797
RUB VISA 4154 8120 7035 2715

@vintagedave
Copy link

Dmitrij, do you have an email I can contact you on, please?

@d-mozulyov
Copy link
Owner

vintagedave,
Hi, sure!
See my contacts in the unit header

@kazalex
Copy link

kazalex commented Jun 13, 2018

But since Delphi 10.1 (Berlin) re-allocation of dynamic arrays is only through the creation of new ones.

What???

program Project1;

{$APPTYPE CONSOLE}

{$R *.res}

uses
  System.SysUtils;

var

 bts : TBytes;
 i   : Integer;
 ptr : Pointer;

begin

 for i := 1 to 10000000 do
  begin

   setlength(bts, i);

   if ptr <> pointer(bts) then // real new array
    begin

     writeln(i);
     ptr := pointer(bts);

    end;

  end;

 readln;

end.

Delphi 10.1:

1
5
53
149
341
725
1493
29477
95877
215989
327653
786405
1769445
3997669
9043941

@nyburner
Copy link

nyburner commented Jun 13, 2018 via email

@kazalex
Copy link

kazalex commented Jun 13, 2018

Ptr not initialized before loop.

Global variables always initialized by zero/nil etc.

@d-mozulyov
Copy link
Owner

kazalex, Thanks, I was a little wrong. But if you change the type of the variable, you will understand what I mean.

var
  bts : TArray<TBytes>;

@dnwerner
Copy link

dnwerner commented Feb 4, 2021

Dear @d-mozulyov ,

I just ran the change you proposed under Delphi 10.3 (using a TArray<TBytes>) and the output of the program was:

1
2
14
38
86
182
374
7370
23970
53998
81914
196602
442362
999418
2260986
5095418

This agrees with what @kazalex wrote and is conflicting with your statement (or it could have been fixed in 10.3)

But since Delphi 10.1 (Berlin) re-allocation of dynamic arrays is only through the creation of new ones.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants