AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Object-Pascal / Delphi-Language Delphi FastShareMem version for Delphi 2009/2010
Thema durchsuchen
Ansicht
Themen-Optionen

FastShareMem version for Delphi 2009/2010

Ein Thema von ijcro · begonnen am 25. Nov 2009 · letzter Beitrag vom 25. Nov 2009
Antwort Antwort
ijcro

Registriert seit: 30. Mär 2006
37 Beiträge
 
Delphi XE Professional
 
#1

FastShareMem version for Delphi 2009/2010

  Alt 25. Nov 2009, 14:17
Hi all!
Exists a new version FastShareMem for Delphi 2009/2010 please?
Thank
ijcro
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.184 Beiträge
 
Delphi 12 Athens
 
#2

Re: FastShareMem version for Delphi 2009/2010

  Alt 25. Nov 2009, 14:37
FastMM v4.94

and set {$define ShareMM} in FastMM4Options.inc

{$define AttemptToUseSharedMM} {$define ShareMMIfLibrary}
$2B or not $2B
  Mit Zitat antworten Zitat
ijcro

Registriert seit: 30. Mär 2006
37 Beiträge
 
Delphi XE Professional
 
#3

Re: FastShareMem version for Delphi 2009/2010

  Alt 25. Nov 2009, 15:49
I made some changes (TMemoryManager<>TMemoryManagerEx) and it works fine.
But there is AllocMemCountAllocMemSize marked as deprecated...



Delphi-Quellcode:
unit FastShareMem;

(*
* Shared Memory Allocator for Delphi DLL's
* Version: 2.10
*
* Features:
*  No runtime dll required.
*  No performance degradation.
*  Faster than ShareMem/Borlndmm.dll.
*
* Usage:
* Windows:
*  Must be the FIRST unit listed in the project file's USES section
*  for both dll and exe projects. If you install a memory manager for
*  leak detection, it should be listed immediately AFTER this unit.
* Linux:
*  Not needed. May be commented out using conditional directives:
*      uses {$IFDEF WIN32} FastShareMem, {$ENDIF}
*
* Author: Emil M. Santos
*  You may use and modify this software as you wish, but this section
*  must be kept intact. Please see Readme.txt for copyright and disclaimer.
*
* Send bugs/comments to [email]fastsharemem@codexterity.com[/email]
* On the web: [url]http://www.codexterity.com[/url]
* To be notified of new versions by email, subscribe to the site alerter facility.

  Revision History:
  2003 Dec 03: Version 2.10. Added GetAllocMemCount and GetAllocMemSize functions.
                From a contribution by Andrey Nikolayevich Aban'shin (andrey@ecobank.san.ru).
  2003 Dec 03: Version 2.00 released. Complete rewrite; now uses a window class
                to exchange data between modules. Safer, and *much* simpler.
                The code is also much shorter.
  2003 Aug 27: Removed reference to SysUtils. This was causing subtle bugs.
                Update by Alex Blach (entwicklung@zmi.de)
  2003 May  7: Fixed "Combining signed and unsigned types" warning. Replaced
            integers with longword where appropriate.
                Thanks to Nagy Krisztián (chris@manage.co.hu)
  2002 Oct  9: Separated MEM_DECOMMIT and MEM_RELEASE calls. Thanks to Maurice Fletcher and Alexandr Kozin.
  2002 Sep  9: Thanks to Ai Ming (aiming@ynxx.com) for these changes:
              Modified to work with Windows NT/2000/XP.
              Added reference-counting mechanism.
  2002 Aug 14: Rewrote address-computation code to better match windows 98
                allocation. VirtualAlloc may round down requested address *twice*.
                Replaced ASSERTs with (lower-level) Win32 MessageBox calls.
                (Thanks to Darryl Strickland (DStrickland@carolina.rr.com))
*)


(*
   Note to contributors:
   If you're going to edit this code, keep in mind the following things:

   * We shouldn't dynamically allocate Delphi 'objects' here, like strings,
      obejcts etc. All memory should come from the Windows API, or be statically
      allocated.

   * We shouln't raise exceptions here, since an exception is a Delphi object,
     and thus consumes heap memory.

    * For the above reasons, we cannot use most VCL facilities here.

*)


interface

var
  GetAllocMemCount: function: integer;
  GetAllocMemSize: function: integer;

implementation

uses Windows;

const
  ClassName = '_com.codexterity.fastsharemem.dataclass';

type
  TFastSharememPack = record
    MemMgr: TMemoryManagerEx;
    _GetAllocMemSize: function: integer;
    _GetAllocMemCount: function: integer;
  end;

function _GetAllocMemCount: integer;
begin
  Result := System.AllocMemCount;
end;

function _GetAllocMemSize: integer;
begin
  Result := System.AllocMemSize;
end;

var
  MemPack: TFastSharememPack;
  OldMemMgr: TMemoryManagerEx;
  wc: TWndClass;
  isHost: boolean;

initialization

if (not GetClassInfo(HInstance, ClassName, wc)) then
begin
  GetMemoryManager(MemPack.MemMgr);
  MemPack._GetAllocMemCount := @_GetAllocMemCount;
  MemPack._GetAllocMemSize := @_GetAllocMemSize;
  GetAllocMemCount := @_GetAllocMemCount;
  GetAllocMemSize := @_GetAllocMemSize;

  FillChar(wc, sizeof(wc), 0);
  wc.lpszClassName := ClassName;
  wc.style := CS_GLOBALCLASS;
  wc.HInstance := HInstance;
  wc.lpfnWndProc := @MemPack;

  if RegisterClass(wc) = 0 then
  begin
    MessageBox(0,
      'Shared Memory Allocator setup failed: Cannot register class.',
      'FastShareMem', 0);
    Halt;
  end;

  isHost := true;
end
else
begin
  GetMemoryManager(OldMemMgr); // optional
  SetMemoryManager(TFastSharememPack(wc.lpfnWndProc^).MemMgr);
  GetAllocMemCount := TFastSharememPack(wc.lpfnWndProc^)._GetAllocMemCount;
  GetAllocMemSize := TFastSharememPack(wc.lpfnWndProc^)._GetAllocMemSize;
  isHost := false;
end;

finalization

if isHost then
  UnregisterClass(ClassName, HInstance)
else
  SetMemoryManager(OldMemMgr); // optional

end.
ijcro
  Mit Zitat antworten Zitat
Benutzerbild von himitsu
himitsu

Registriert seit: 11. Okt 2003
Ort: Elbflorenz
44.184 Beiträge
 
Delphi 12 Athens
 
#4

Re: FastShareMem version for Delphi 2009/2010

  Alt 25. Nov 2009, 16:24
Zitat von ijcro:
But there is AllocMemCount AllocMemSize marked as deprecated...
this are functions from old Delphi-MemoryManager
instead, use GetMemoryManagerState
$2B or not $2B
  Mit Zitat antworten Zitat
Antwort Antwort


Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 15:48 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz