[Geany] do not open oversize files

Lex Trotman elextr at xxxxx
Wed Jan 5 00:08:18 UTC 2011


2011/1/5 Krzysztof Żelechowski <giecrilj at stegny.2a.pl>:
> Dnia wtorek, 4 stycznia 2011 o 20:19:55 Dimitar Zhekov napisał(a):
>> On Tue, 4 Jan 2011 19:43:23 +0100
>> Krzysztof Żelechowski <giecrilj at stegny.2a.pl> wrote:
>>
>> > Dnia wtorek, 4 stycznia 2011 o 18:22:42 Dimitar Zhekov napisał(a):
>> > > As a crude estimate, under Linux you can try to malloc(minimal
>> > > presumable required memory). It won't be actually allocated, unless you
>> > > memset() it or something, but if the result is NULL, a warning is
>> > > justified.
>> > >
>> >
>> > I do not know where you got it from, but the last OS I know that
>> > behaved like that was MacOS 7. [cut]
>>
>> Like what?..
>
> Like necessarily allocating a contiguous block of physical memory.  GNU malloc uses mmap so it is all virtual.


And on modern kernels virtual memory can be overcommitted
significantly, so it may not work & is expensive since the page tables
have to be constructed even if the memory is not used.

Also this could cause fragmentation of the virtual address space that
may limit how many times it will work.

If you really want to do something then a warning "this is a big file
are you sure you want to open it" using a hidden pref is the most
sensible, with a pref value of zero meaning no check so people like me
with 4G can turn it off.

Cheers
Lex

>
>>
>> > malloc fails at 01 << 040 at my place.
>>
>> And so? On the machine I'm currently at: kernel 2.6.32, glibc-2.1,
>> 512MB RAM + 512MB virtual, single malloc fails at ~640MB.
>>
>> If by "01 << 040" you mean 4GB, how much real and virtual memory do
>> you have?
>>
>>
>
> I have 1 GB of physical memory.  (01 << 040) is the first integer that does not fit into unsigned int.
>
> Chris
> _______________________________________________
> Geany mailing list
> Geany at uvena.de
> http://lists.uvena.de/cgi-bin/mailman/listinfo/geany
>



More information about the Users mailing list