473,411 Members | 1,889 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

fwrite and memory error

I'm trying to save an XML file sent to me in ZIP format.
Here is the code:
if($XMLFile=fopen($XMLPath.strtoupper(substr($file ,0,strlen($file)-4)).".XML",'w'))
if(fwrite($XMLFile,zip_entry_read($zip_entry,zip_e ntry_filesize($zip_entry)))){

here is the error:
Allowed memory size of 8388608 bytes exhausted (....)

The problem occurs on the "fwrite" function.

This appens when the XML file is very large (seems more than the 8mb limit).

I can't change this size server side, as my ISP doesn't allow me to do that.

Hot to fix the problem script side ???

Bob

Jul 17 '05 #1
3 3546
Bob Bedford wrote:
if($XMLFile=fopen($XMLPath.strtoupper(substr($fil e,0,strlen($file)-4)).".XML",'w')) if(fwrite($XMLFile,zip_entry_read($zip_entry,zip_ entry_filesize($zip_entry)))){

Try not writing the entire zip at once, but do it a bit at a time so
there never has to exist a variable that is larger than 8 MB.

--
Rasmus Rimestad, webprogrammer
http://www.rimestad.no/en

----== Posted via Newsfeeds.Com - Unlimited-Uncensored-Secure Usenet News==----
http://www.newsfeeds.com The #1 Newsgroup Service in the World! 120,000+ Newsgroups
----= East and West-Coast Server Farms - Total Privacy via Encryption =----
Jul 17 '05 #2
"Rasmus Rimestad" <""rasmus\"@ri***********@am.no"> a écrit dans le message
de news: 42********@127.0.0.1...
Bob Bedford wrote:
if($XMLFile=fopen($XMLPath.strtoupper(substr($fil e,0,strlen($file)-4)).".XML",'w'))

if(fwrite($XMLFile,zip_entry_read($zip_entry,zip_ entry_filesize($zip_entry)))){

Try not writing the entire zip at once, but do it a bit at a time so there
never has to exist a variable that is larger than 8 MB.


I've been looking around without finding a way to do so. Could you please
tell me how ?

Bob
Jul 17 '05 #3
The manual says that if you do not specify the size you want to read in
zip_entry_read then it will read 1024 bytes. Have you tried something
like this?

while($size < zip_entry_filesize($zip_entry)) {
fwrite($XMLFile,zip_entry_read($zip_entry));
$size += 1024;
}

Rasmus Rimestad
Web databases at a price you can live with -> http://www.rimestad.no
Jul 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Tuuska | last post by:
Hello! I have this problem, when fwrite() writes to the beginning of xyz.txt file, it overwrites the first line. Any ideas how to prevent this? I'm running PHP 4.3.3RC3 on Linux. <?php $fp =...
3
by: seia0106 | last post by:
Hello In the course of writing a program. I have to read and write a media file(*.avi/*.mpg/*.wav) to and from memory buffer. I can put the data(from a *.avi file)in buffer successfully but when...
23
by: FrancisC | last post by:
how to use fwrite( ) instead of fprintf( ) in this case? I want to generate binary file. FILE *fnew; int i, intName; double array; fprintf(fnew, "%d\n", intName);...
15
by: Suraj Kurapati | last post by:
Hello, I'm having a rather strange bug with this code: for certain values of 'buf', a segmentation fault occurs when 'free(buf)' is followed by an 'fwrite()'. In the program output, there is no...
10
by: cs | last post by:
if i have typedef struct{ unsigned a; unsigned *b; }tp; i would like to ask if it is ok for the "C standard 89" doing something like this {
4
by: ibrahimover | last post by:
typedef struct{ char name; int no; }TAM; typedef struct{ char name; char ch; }HARF;
4
by: janssenssimon | last post by:
//de structure om de highscores in op de slagen typedef struct score{ char *naam; int veld; int score; struct score *volg; }HIGH; void toonhighscores(void)
10
by: Sheldon | last post by:
Hi, I am trying to learn C from scratch and, though I do know how to program in Python, many things in C are hard to understand - even after reading the examples. I guess because so many...
12
by: arnuld | last post by:
WANTED: Even if I do Ctrl-C in the middle of fgets(), fwrite() should write the previously entered data to a file (except if I hit the file-size limit) PROBLEM: If I do a Ctrl-C in the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.