Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Начинающим";
Текущий архив: 2007.02.04;
Скачать: [xml.tar.bz2];

Вниз

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;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.47 MB
Время: 0.048 c
4-1158843366
GanibalLector
2006-09-21 16:56
2007.02.04
Передача строки из доп.потока с основной


4-1157143168
NeiRo_St
2006-09-02 00:39
2007.02.04
Web-camera


2-1169118311
FIL-23
2007-01-18 14:05
2007.02.04
как узнать номер позиции указателя в таблице?


15-1168888548
властелин колхоза
2007-01-15 22:15
2007.02.04
дефрагментатор встроенный


15-1168608312
kaZaNoVa
2007-01-12 16:25
2007.02.04
Идеальная защита лицензионного ПО





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский