Главная страница
Top.Mail.Ru    Яндекс.Метрика
Текущий архив: 2007.02.04;
Скачать: CL | DM;

Вниз

DLL   Найти похожие ветки 

 
KygECHuK ©   (2007-01-16 16:00) [0]

При вызове финкций из библиотек использую переменные динамической длинны. Где-то читал что, это может вызывать проблемы. У меня иногда появляются ошибки доступа к памяти при выгрузке библиотеки. Я думаю что это связанно именно с такими переменными


 
Орион ©   (2007-01-16 16:01) [1]

ShareMem подключил?


 
Сергей М. ©   (2007-01-16 16:03) [2]


> Где-то читал


Ты это читал в здоровущем комментарии, который вставляет IDE в текст любого нового dll-проекта.


 
ors_archangel ©   (2007-01-17 02:26) [3]

Очень рекомендую:

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 fastsharemem@codexterity.com
* On the web: http://www.codexterity.com
* 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: TMemoryManager;
   _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: TMemoryManager;
 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.

- нет потерь в скорости, можешь забыть о проблемах с динамическими структурами, намного лучше ShareMem, - с прогой никаких DLL таскать не надо и потерь в скорости нет.


 
KygECHuK ©   (2007-01-17 14:13) [4]

Спасиба. Вот только год не программировал- а уже к начинающим. жаль :(


 
Джо ©   (2007-01-17 14:32) [5]

> [4] KygECHuK ©   (17.01.07 14:13)
> Вот только год не программировал- а уже к начинающим.
> жаль :(

Такая постановка вопроса именно для данной конференции и типична. А также явное нежелание самому брать информацию, расположенную под самым носом (см. [2]).



Страницы: 1 вся ветка

Текущий архив: 2007.02.04;
Скачать: CL | DM;

Наверх




Память: 0.48 MB
Время: 0.047 c
2-1169219514
Linu_X_oid
2007-01-19 18:11
2007.02.04
Объясните, пожалйста, как можно нормально создать чат в Delphi 7


15-1168520149
AleXerON
2007-01-11 15:55
2007.02.04
Cортировщик уинов


2-1169068778
Kostafey
2007-01-18 00:19
2007.02.04
Как удилить в строке пробелы ?


3-1163659092
Ega23
2006-11-16 09:38
2007.02.04
Что отработает раньше: TDataSet.OnCalcField


15-1168892874
@!!ex
2007-01-15 23:27
2007.02.04
редактор ТЕХа