GithubHelp home page GithubHelp logo

d-mozulyov / brainmm Goto Github PK

View Code? Open in Web Editor NEW
96.0 96.0 16.0 1014 KB

Extremely fast memory manager for Delphi

Home Page: http://www.sql.ru/forum/1213139/ekstremalno-bystryy-menedzher-pamyati-brainmm

License: MIT License

Pascal 99.65% PHP 0.35%

brainmm's People

Contributors

d-mozulyov avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

brainmm's Issues

runtime error on second programm instance

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.

Compiling problems: E2201 error

Hi!
I'm creating a package that merely contains the brainmm.pas unit. When I compile it, next error appears: E2201 need imported data reference ($G) to access 'ReportMemoryLeaksOnShutdown' from unit 'BRainMM'. I have tried with that directive, also with the '{$IMPORTEDDATA ON}' after reading in the web some similar errors, but can't make it compile... :(
If I use the brainmm in a normal proyect (no packages), no problem. But when you use packages in any way, the problem appears and don't know how to solve it
Any idea what is happening?

List the license explicitly in the (c) block.

It's not clear to me under what license you're making the project available.
It reads like the MIT license.
It would help if you make explicit whether it is BSD, MIT, Mozilla etc.
You might also want to dual license it so that more people can use it potentially.

Error under Delphi7

{$ifdef MSWINDOWS}
const
BRAINMM_MARKER: array[1..18] of WideChar = 'Local\BrainMM_PID_';
HEX_CHARS: array[0..15] of WideChar = '0123456789ABCDEF';

Those lines return me a incompatible array's and string error, when I try to compile under Delphi7...
what is the consequence if we use used char instead of Widechar (with char, and OpenFileMapping, CreateFileMapping I can compile it...) ?

Win64 Service Crash

Hello,
if you use BrainMM under Win64 Service it will crash the service. (it will not start)

Thank you

Crash with lots of threads on x64 executable

Hello,

We are developing a massively parallel application and are hitting the limits of the default Delphi memory allocator in this situation.
As a result, we are investigating replacements for which BrainMM appears to be a very promising candidate.
However, we are hitting an issue where we get InvalidPtr exceptions in the x64 version of our application. We narrowed it down to the following command line application:

program BrainMMTest;

{$APPTYPE CONSOLE}

uses
  BrainMM,
  System.Diagnostics,
  System.TimeSpan,
  System.SysUtils,
  System.Classes,
  System.Generics.Collections,
  Winapi.Windows;

{$R *.res}

type
  TTestThread = class(TThread)
  public
    procedure Execute; override;
  end;

var
  Stopwatch: TStopwatch;
  Elapsed: TTimeSpan;
  ThreadList: TList<TThread>;
  Threads: array of TTestThread;
  iGlobal: Integer;

const
  C_StrL = 16351;

{ TTestThread }

procedure TTestThread.Execute;
var
  CurrentStringList: TStringList;
  i: Integer;
  CurrentString: string;
begin
  CurrentStringList := TStringList.Create;
  try
    for I := 1 to 1571000 do
    begin
      SetLength(CurrentString, C_StrL);
      SetLength(CurrentString, 0);
      CurrentStringList.Add(IntToStr(Random(i)) + 'bob' + IntToStr(Random(i)));
    end;
  finally
    CurrentStringList.Free;
  end;
end;

begin
  try
    Stopwatch := TStopwatch.StartNew;

    SetLength(Threads, 40); // highly parallel
    ThreadList := TList<TThread>.Create;
    try
      for iGlobal := Low(Threads) to High(Threads) do
      begin
        Threads[iGlobal] := TTestThread.Create;
        ThreadList.Add(Threads[iGlobal]);
      end;

      while ThreadList.Count > 0 do
      begin
        if ThreadList[0].WaitFor = WAIT_OBJECT_0 then
          ThreadList.Delete(0);
        Sleep(10);
      end;
    finally
      ThreadList.Free;
    end;

    Elapsed := Stopwatch.Elapsed;
    Writeln(Format('BrainMM took %n milliseconds', [Elapsed.TotalMilliseconds]));
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
  readln;
end.

In 32bits mode, either debug or release, it works fine and takes about 15s on my computer.

In 64bits mode, either debug or release, it rarely works in which case it takes about 7s. But most often, and even more so when run via the IDE (Delphi Seattle) it crashes almost immediately.

Looking at the call stack, the exception is raised by RaiseInvalidPtr from ResizeDifficult itself being called by BrainMMReallocMem which seems quite logical as the program above does a lot of memory reallocation.

Fiddling with different options, we discovered that defining PUREPASCAL at the top of the BrainMM unit makes the error disappear, which hints that the issue may be in the x64 version of the assembly code for BrainMMReallocMem.

However, we were not able to figure out what's wrong in that code, it's a bit too difficult for us to understand, let alone offer a fix.

Any suggestion would be most welcome.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.