Commit Graph

182 Commits

Author SHA1 Message Date
Rika Ichinose
ba7a76bf37 Allow MemSize(nil) to match FreeMem(nil). 2024-10-27 21:49:05 +03:00
Rika Ichinose
c08d73054a Return MemSize from FreeMem. 2024-10-27 21:44:01 +03:00
florian
4e1f854d49 * patch by Rika + test: Don’t explicitly change GetMem(0) to GetMem(1), it works anyway, resolves #40456 2024-03-01 22:49:45 +01:00
Michaël Van Canneyt
fb5b891c45 * Fix issue #40360 2023-07-23 23:32:37 +02:00
florian
c0372f80e0 * with section threadvars, heap relocation is not needed
git-svn-id: trunk@43130 -
2019-10-05 20:48:27 +00:00
svenbarth
c1e3c61af3 * don't call the memory manager's functions, but instead call the Sys* functions directly
git-svn-id: trunk@42797 -
2019-08-24 10:37:20 +00:00
svenbarth
db2a5285a9 * fix for Mantis #35988: the internal heap uses directly the Sys* functions, not the memory manager
git-svn-id: trunk@42774 -
2019-08-23 14:59:15 +00:00
florian
f0213a2c46 + make use of the mremap syscall of linux to re-allocate large memory blocks faster
git-svn-id: trunk@42713 -
2019-08-16 20:47:37 +00:00
marco
8c854cedee * more case fixes, mantis #32832 manually done.
git-svn-id: trunk@38865 -
2018-04-29 14:05:09 +00:00
michael
aaf0647f58 * Fix bug ID #31462: sysreallocmem uses sys* routines instead of installed memmanager routines
git-svn-id: trunk@36769 -
2017-07-23 09:23:02 +00:00
pierre
6c43882cf5 Allow compilation with -Sfnothreading
git-svn-id: trunk@36092 -
2017-05-04 21:18:22 +00:00
pierre
a72434e93a Trial to clarify heap for i8086 issues:
- MSDOS heap in tinyheap.inc modified to use usual
  SysGetMem and similar names.
  - Use HAS_MEMORYMANAGER (used previously in wince source code,
  to specify that a memory manager is defined elsewhere than inside
  heap.inc include file.
  - Use
  - Remove TinyHeapMemoryManager Structure variable completely

  heaptrc.pp: remove unneeded macro code after name changes of tinyheap.inc

  msdos/system.pp now only defines HAS_MEMORYMANAGER macro
  win16/system.pp defines HAS_MEMORYMANAGER and FPC_NO_DEFAULT_HEAP
  as it still uses a different memory manager.
  __stkbottom variable added for win16 system.pp as it is required
  by i8086 specific stack check code.

git-svn-id: trunk@33983 -
2016-06-13 22:26:03 +00:00
pierre
effa0154c5 Use FPC_NO_DEFAULT_MEMORYMANAGER define to guard SysGetmem/SysFreemem functions, also used for msdos OS
git-svn-id: trunk@33678 -
2016-05-11 14:33:00 +00:00
sergei
8ad5e6fb26 - RTL: cleaned out FPC_FREEMEM_X. We now have a dedicated compilerproc 'fpc_freemem' for this purpose.
git-svn-id: trunk@27232 -
2014-03-23 02:11:38 +00:00
nickysn
4e2962e6ae - do not initialize the regular heap manager under i8086-msdos, so it can be smartlinked away
git-svn-id: trunk@24614 -
2013-05-25 19:22:31 +00:00
pierre
503b8c73c2 Avoid infinite loops with RTE 204 if heap is corrupted
git-svn-id: trunk@23845 -
2013-03-15 15:40:23 +00:00
Jonas Maebe
198625af47 * fixed memory statistics after try_concat_free_chunk_forward() concatenated
some blocks, but the result was still not large enough to satisfy a
    reallocmem call (mantis #14315)

git-svn-id: trunk@22249 -
2012-08-26 15:29:44 +00:00
florian
6a1a2d3464 * get rid of some feature checks, probably the whole feature stuff is plainly the wrong way, embedded rtl compiles again, resolves #20913
git-svn-id: trunk@19907 -
2011-12-29 14:06:30 +00:00
sergei
bcbd25568e * Call InitHeap before InitSystemThreads in TLS callback (necessary because InitSystemThreads calls RelocateHeap), and skip both of them in initialization section of system.pp if they have been called from TLS callback. This restores correct initialization sequence which was broken by r19779, resulting in lots of debug messages about corrupted heap when running tests/test/theapthread.pp
git-svn-id: trunk@19836 -
2011-12-13 07:40:02 +00:00
florian
375f83c874 * moved heap manager on embedded systems into a separate unit
* moved console io on embedded systems into a seperate unit, this unit might setup input/output e.g. to be redirected to a serial port
* cleanup of the embedded system unit

git-svn-id: trunk@19168 -
2011-09-21 20:57:37 +00:00
sergei
3e145f6d77 + RelocateHeap: tolerate being called more than once.
git-svn-id: trunk@17762 -
2011-06-16 18:57:36 +00:00
Jonas Maebe
7cb1c8b586 * improvement of r16001 so that allocations even closer to high(ptruint)
also fail correctly rather than overflowing to 0 bytes (mantis #18690)

git-svn-id: trunk@16877 -
2011-02-04 18:58:21 +00:00
florian
f90acc40d9 * made GetMemory, FreeMemory, ReallocMemory delphi compatible, resolves #17530
git-svn-id: trunk@16075 -
2010-10-02 19:15:58 +00:00
Jonas Maebe
242016312f * immediately fail when trying to allocate a memory block whose size falls
in the range high(ptruint)-$fffe .. high(ptruint), because all large
    allocations are rounded up to the next multiple of 64kb, which is 0 in
    that case (mantis #17430)

git-svn-id: trunk@16001 -
2010-09-17 14:05:06 +00:00
Jonas Maebe
56f8b88125 * also initialise locgrowheapsizesmall in InitHeapThread, should fix crashes
on Windows after r15618 (not sure why things worked fine elsewhere)

git-svn-id: trunk@15688 -
2010-08-02 14:08:21 +00:00
micha
829f8164fc * rtl/heap: simplify r15618, be more conservative towards memory use, especially since performance improvement is hardly measurable
git-svn-id: trunk@15636 -
2010-07-25 17:23:15 +00:00
Jonas Maebe
e150c2c521 * dynamically grow the size of oschunks allocated for use by the memory
pools for small blocks (fixedfreelists) when lots of such oschunks
    are allocated successively, in order to reduce the overhead of
    allocating such chunks from the OS (and of freeing them afterwards)

git-svn-id: trunk@15618 -
2010-07-20 10:54:21 +00:00
Jonas Maebe
8a891690cc * prefetch heap status in sysfreemem
* re-layouted code in sysfreemem_fixed so that the most likely case is on
    the fall-through path
  * moved dec(poc^.used) in sysfreemem_fixed earlier so that it doesn't
    cause a dependency stall for the "if poc^.used<=0" test later

git-svn-id: trunk@15515 -
2010-07-03 12:45:55 +00:00
micha
347d71db10 * rtl/heap: optimization, while looking for a big enough block, also use blocks that are exactly large enough
git-svn-id: trunk@14420 -
2009-12-12 09:37:36 +00:00
micha
a6e6e9d453 * rtl/heap: fix SysReallocMem corruption in multi-thread use (thanks to Burkhard Carstens, #15323)
git-svn-id: trunk@14419 -
2009-12-12 09:28:41 +00:00
Jonas Maebe
c1408d164f * added some prefetch commands based on profile information about
l2 misses

git-svn-id: trunk@14197 -
2009-11-16 00:18:34 +00:00
Jonas Maebe
0597c300f4 * applied feature dependencies patch by Sven Barth from mantis #13673 :
o i386/i386.inc used a function (fpc_truely_ansistr_unique) is now
     only included if FPC_HAS_FEATURE_ANSISTRINGS is enabled (all other
     platforms use the Pascal-only implementations)
   o inc/heap.inc relied on threading
   o inc/threads.inc relied on exceptions, consoleio and stackcheck
   o inc/system.inc: just a feature-related "variable not used"-hint

git-svn-id: trunk@13121 -
2009-05-09 20:08:57 +00:00
Jonas Maebe
533f533868 * changed destination parameter of getmem/getmemory from "var" to "out"
(mantis #11907)

git-svn-id: trunk@13036 -
2009-04-25 09:57:29 +00:00
micha
82e9d9009d * fix memory leak introduced in rev 9696, orphaned os chunks are not reused for short-lived threads (fixes issue #13173)
git-svn-id: trunk@12759 -
2009-02-20 22:35:41 +00:00
micha
ae8289f9f7 * fix crash in case of main thread exiting simultaneously with other threads (issue #11006)
git-svn-id: trunk@10492 -
2008-03-15 19:42:30 +00:00
Jonas Maebe
eb83213f10 * Only start recycling oschunks once MaxKeptOSChunks chuncks have
been allocated. E.g. allocate 100 blocks of 80 bytes and free them
    all, then the same with blocks of 96, 112, 128, 144, 160 and 176
    bytes, after which again 80 bytes -> previously, regardless of
    the value of MaxKeptOSChunks, the empty block for 80 bytes was
    reformatted for those of 96 bytes, then for 112 bytes etc. Now,
    if MaxKeptOSChunks is set to 7, none will ever be reformatted
    because enough chunks will be allocated from the OS.

git-svn-id: trunk@9696 -
2008-01-09 20:39:59 +00:00
Jonas Maebe
588822b14d * more ptruint type casts to avoid 64 bit comparisons on 32 bit
platforms

git-svn-id: trunk@9693 -
2008-01-09 18:32:37 +00:00
Jonas Maebe
6dd8e51ee5 * folded a constant addition
* typecasted a subtraction's result to ptruint to avoid a needless
    64 bit calculation on 32 bit platforms

git-svn-id: trunk@9673 -
2008-01-07 21:28:58 +00:00
peter
5acb3649df * revert r9557, the performance impact is to big for an academic corner
case optimziation

git-svn-id: trunk@9603 -
2007-12-31 13:36:16 +00:00
yury
0dcad4d822 * Implemented late thread manager initialization. Thread manager code is not included to executable if thread stuff are not used. WinCE executable size is reduced by 4KB, Win32 executable size is reduced by 3KB. No testsuite regressions.
git-svn-id: trunk@9557 -
2007-12-28 14:40:28 +00:00
yury
e00bacdcef * Removed HAS_MT_MEMORYMANAGER define, since it is obsolete now.
git-svn-id: trunk@9556 -
2007-12-28 11:30:46 +00:00
yury
eadfbb5027 * Removed unused local variable.
git-svn-id: trunk@9553 -
2007-12-27 23:49:35 +00:00
yury
b55501afef * Removed dead code.
git-svn-id: trunk@9507 -
2007-12-21 23:23:55 +00:00
Jonas Maebe
b02fd37fbe * removed some unused variables
git-svn-id: trunk@8399 -
2007-09-08 08:45:12 +00:00
Legolas
87d67dcad6 * gba and nds work with new heap manager now (no need for a custom heap manager that allocates a single big block anymore)
git-svn-id: trunk@8200 -
2007-07-30 15:37:19 +00:00
daniel
0c3a2a257d * Convert heap to ptruint.
git-svn-id: trunk@7950 -
2007-07-04 19:46:47 +00:00
micha
b8822c88b5 * fix heap manager adding to wrong free list, and race condition
git-svn-id: trunk@7878 -
2007-06-30 21:13:48 +00:00
micha
cd1a283a18 * fix heap var size chunk search to be as intended (search constant number of blocks from best, not from any bigger)
git-svn-id: trunk@7807 -
2007-06-24 21:50:05 +00:00
micha
afb5f32f65 * fix heap block recycle flag when orphaning
git-svn-id: trunk@7805 -
2007-06-24 21:32:31 +00:00
micha
787f9a44c7 * heap manager: do not try to leave critical section twice, moron
git-svn-id: trunk@7763 -
2007-06-21 20:19:33 +00:00