🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.delphi.language.objectpascal
Article #48

Huge strings and Out of Memory

#48
From: SH
Date: Thu, 10 Nov 2005 20:46
34 lines
2010 bytes
Hi

I have a simple application containing this code:
---
var s : string;
begin
  setlength(s, 1024*1024*512);
  showmessage('ok');
  setlength(s, 1024*1024*1024);
  showmessage('ok');
  ...
---

The problem is that Delphi spits our an 'Out of Memory' error even though
there's more than 1.2GB free memory available

On the other hand, this code works fine:
---
var s : string;
begin
  setlength(s, 1024*1024*1024);
  showmessage('ok');
  ...
---

So it seems like Delphi creates a whole new memory allocation containing
'1024*1024*1024' bytes before unassigning any of the previosuly assigned
'1024*1024*512' bytes.

Is there a work-around for this, so I can make the first code example above
work?

Thanks in advance
  Simon
Technical Details
Message-ID: <9qydnQ3xkv1fLO7eRVn-ug@giganews.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Thread: 109d30,df067a911d24cc04,start
X-Google-Attributes: gid109d30,public
X-Google-Language: ENGLISH,ASCII-7-bit
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!newsread.com!news-xfer.newsread.com!news.glorb.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!news.giganews.com.POSTED!not-for-mail
NNTP-Posting-Date: Thu, 10 Nov 2005 14:46:58 -0600
From: "SH" <blah@spam.com>
Newsgroups: borland.public.delphi.language.objectpascal
Subject: Huge strings and Out of Memory
Date: Thu, 10 Nov 2005 21:46:57 +0100
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-RFC2646: Format=Flowed; Original
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
Message-ID: <9qydnQ3xkv1fLO7eRVn-ug@giganews.com>
Lines: 36
X-Trace: sv3-WZ4FGbLT9ppghCNY2+Pvg99aa3s4pUsGlFDTC9TTBz0S9DZAVjQMtzTWn2SpRkzozpRHk+5TJUfLF7s!yPXgFAJ8ZuLJk4haxIYk0vBBPaMK23MrkAKuTjySIfB3aSkKv9MmBLReIEOlNiY=
X-Complaints-To: abuse@giganews.com
X-DMCA-Notifications: http://www.giganews.com/info/dmca.html
X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers
X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly
X-Postfilter: 1.3.32