[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Errno::ENOMEM reading a device in Ruby, not in Java though

Roger Pack

1/28/2009 8:27:00 PM

Question on how to avoid an Errno::ENOMEM

Currently if I open a tape device from my machine [/dev/st2]
in ruby reading the second file from it results in:

read.rb:2:in `read': Cannot allocate memory - /dev/st2 (Errno::ENOMEM)
from read.rb:2

Java to do the same works, however.

the "cat" command [i.e. cat </dev/st2] also fails with "Not enough
memory"

Here is an strace of the two:

ruby:

open("/dev/st2", O_RDONLY) = 3
fstat(3, {st_mode=S_IFCHR|0660, st_rdev=makedev(9, 2), ...}) = 0
fstat(3, {st_mode=S_IFCHR|0660, st_rdev=makedev(9, 2), ...}) = 0
ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff5721d900) = -1 EINVAL
(Invalid argument)
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
= 0x2b5b53902000
read(3, 0x2b5b53902000, 4096) = -1 ENOMEM (Cannot allocate
memory)


java:

[pid 25476] open("/dev/nst2", O_RDONLY) = 4
[pid 25476] fstat(4, {st_mode=S_IFCHR|0660, st_rdev=makedev(9, 130),
...}) = 0
[pid 25476] mprotect(0x2aab3409b000, 65536, PROT_READ|PROT_WRITE) = 0
[pid 25476] read(4, "<familysearch-format>\n<type name"..., 65536) = 116

Anybody know if the difference between mmap and mprotect might be
causing this?
Thanks!
-=r
--
Posted via http://www.ruby-....

3 Answers

Heesob Park

1/29/2009 5:47:00 AM

0

2009/1/29 Roger Pack <rogerpack2005@gmail.com>:
> Question on how to avoid an Errno::ENOMEM
>
> Currently if I open a tape device from my machine [/dev/st2]
> in ruby reading the second file from it results in:
>
> read.rb:2:in `read': Cannot allocate memory - /dev/st2 (Errno::ENOMEM)
> from read.rb:2
>
> Java to do the same works, however.
>
> the "cat" command [i.e. cat </dev/st2] also fails with "Not enough
> memory"
>
> Here is an strace of the two:
>
> ruby:
>
> open("/dev/st2", O_RDONLY) = 3
> fstat(3, {st_mode=S_IFCHR|0660, st_rdev=makedev(9, 2), ...}) = 0
> fstat(3, {st_mode=S_IFCHR|0660, st_rdev=makedev(9, 2), ...}) = 0
> ioctl(3, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fff5721d900) = -1 EINVAL
> (Invalid argument)
> mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0)
> = 0x2b5b53902000
> read(3, 0x2b5b53902000, 4096) = -1 ENOMEM (Cannot allocate
> memory)
>
>
> java:
>
> [pid 25476] open("/dev/nst2", O_RDONLY) = 4
> [pid 25476] fstat(4, {st_mode=S_IFCHR|0660, st_rdev=makedev(9, 130),
> ...}) = 0
> [pid 25476] mprotect(0x2aab3409b000, 65536, PROT_READ|PROT_WRITE) = 0
> [pid 25476] read(4, "<familysearch-format>\n<type name"..., 65536) = 116
>
> Anybody know if the difference between mmap and mprotect might be
> causing this?
The another difference between ruby and java is read buffer size.
Ruby's buffer size is 4096 and java's buffer size is 65536.

The man page of st says:

RETURN VALUE

ENOMEM The byte count in read() is smaller than the next physi-
cal block on the tape. (Before 2.2.18 and 2.4.0-test6 the
extra bytes have been silently ignored.)

Refer to http://fts.ifac.cnr.it/cgi-bin/dwww?type=runman&loc...

Regards,

Park Heesob

Oldjay

12/17/2009 8:21:00 PM

0

I can't find any properties window that references the caption (the text at
the very top of the user form).

"JLGWhiz" wrote:

> Yes. In the properties window for a userform, click on font and it opens a
> dialog box to choose the style, size, color, etc. You can also do it by
> code.
>
> With UserForm1.Font
> .Name = "Arial"
> .Size = 12
> .ColorIndex = 3
> End With
>
>
>
> "oldjay" <oldjay@discussions.microsoft.com> wrote in message
> news:91A74F50-379A-42E2-8345-6A027170C287@microsoft.com...
> > Can you change the caption font size of a user form?
>
>
> .
>

JLGWhiz

12/17/2009 10:46:00 PM

0

My mistake. That only applies to text entries on the user form. To change
the Title Bar caption you will have to go to the Appearance feature for
windows. The title bar for the user form is not an Excel application
feature, it is a Windows application feature. When you change it, it
applies to all other workbooks and applications such as Word, Power Point,
Access, etc. You can access the Appearance dialog box by a right click on
your desk top screen and select properties from the pop up menu. Select the
Appearance tab then click the Advanced button. To change features of
windows attributes, click on the object you want to change, in this case the
Active Title Bar. Make your adjustments and click OK.



"oldjay" <oldjay@discussions.microsoft.com> wrote in message
news:4234CCF7-A140-4EC4-B8D9-03E8114C3B62@microsoft.com...
>I can't find any properties window that references the caption (the text at
> the very top of the user form).
>
> "JLGWhiz" wrote:
>
>> Yes. In the properties window for a userform, click on font and it opens
>> a
>> dialog box to choose the style, size, color, etc. You can also do it by
>> code.
>>
>> With UserForm1.Font
>> .Name = "Arial"
>> .Size = 12
>> .ColorIndex = 3
>> End With
>>
>>
>>
>> "oldjay" <oldjay@discussions.microsoft.com> wrote in message
>> news:91A74F50-379A-42E2-8345-6A027170C287@microsoft.com...
>> > Can you change the caption font size of a user form?
>>
>>
>> .
>>