By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,278 Members | 1,357 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,278 IT Pros & Developers. It's quick & easy.

php mmap and munmap

P: n/a
Looking at the php manual site, I don't see where php
supports memory mapped file IO.
Is that right? Or are mmap and munmap called something else?
Aug 14 '08 #1
Share this Question
Share on Google+
6 Replies


P: n/a
On Aug 14, 2:18*pm, osnot <davidos...@not.netwrote:
Looking at the php manual site, I don't see where php
supports memory mapped file IO.
Is that right? Or are mmap and munmap called something else?
Even if it had memory mapped file I/O, how would you access the
memory?

C and PHP are on different levels altogether. Use fread() or
file_get_contents() to read a file. Why would you want mmap()?
Aug 14 '08 #2

P: n/a
Sjoerd wrote:
On Aug 14, 2:18 pm, osnot <davidos...@not.netwrote:
>Looking at the php manual site, I don't see where php
supports memory mapped file IO.
Is that right? Or are mmap and munmap called something else?

Even if it had memory mapped file I/O, how would you access the
memory?

C and PHP are on different levels altogether. Use fread() or
file_get_contents() to read a file. Why would you want mmap()?
....."The primary benefit of memory mapping a file is increased I/O
performance, especially when used on small files. Accessing memory
mapped files is faster than using direct read and write operations for
two reasons."
Aug 14 '08 #3

P: n/a
On Aug 14, 3:14*pm, osnot <davidos...@not.netwrote:
...."The primary benefit of memory mapping a file is increased I/O
performance, especially when used on small files. Accessing memory
mapped files is faster than using direct read and write operations for
two reasons."
Maybe you can tell us about your performance problem, so that we can
offer suggestions to increase performance with methods that are
available in PHP.
Aug 14 '08 #4

P: n/a
osnot wrote:
Sjoerd wrote:
>On Aug 14, 2:18 pm, osnot <davidos...@not.netwrote:
>>Looking at the php manual site, I don't see where php
supports memory mapped file IO.
Is that right? Or are mmap and munmap called something else?

Even if it had memory mapped file I/O, how would you access the
memory?

C and PHP are on different levels altogether. Use fread() or
file_get_contents() to read a file. Why would you want mmap()?

...."The primary benefit of memory mapping a file is increased I/O
performance, especially when used on small files. Accessing memory
mapped files is faster than using direct read and write operations for
two reasons."
Chances are if the data are used often enough, they'll already be in
memory (the OS's file system cache). And if they're used less often,
they'll be taking up memory all the time (a minimum 4K per file, even if
it's only a 2 byte file). In this case, while access to the data itself
would be faster, not being able to use the memory for other things could
actually slow system performance.

In over 20 years of C programming, I've seldom found a good use for
memory mapped files. And most of the uses I've seen are unnecessary.

--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================

Aug 14 '08 #5

P: n/a
Sjoerd wrote:
On Aug 14, 3:14 pm, osnot <davidos...@not.netwrote:
>...."The primary benefit of memory mapping a file is increased I/O
performance, especially when used on small files. Accessing memory
mapped files is faster than using direct read and write operations for
two reasons."

Maybe you can tell us about your performance problem, so that we can
offer suggestions to increase performance with methods that are
available in PHP.
....I had a vague, fuzzy idea about how to handle interative manipulation
of a file. I thought I'd mmap it once, manipulate it many times, and
then write it out to disk only at the end of a long series of
manipulations. But the more I think about it, the less I like that idea
anyway. I get these ideas sometimes--they pop up like weeds, and then
go away. Sometimes they turn into flowers. But usually not.
Aug 14 '08 #6

P: n/a
osnot wrote:
Looking at the php manual site, I don't see where php
supports memory mapped file IO.
PHP supports it since 5.1.* with 'php://memory' Stream.

e.G.: fopen('php://memory', 'wb')

PHP-Manual contains a description for it. see here ↓

PHP input/output streams:
http://de.php.net/wrappers.php

So long, Ulf
Aug 14 '08 #7

This discussion thread is closed

Replies have been disabled for this discussion.