How can you copy (clone) a string?

Peter.Rupp at ual.com Peter.Rupp at ual.com
Tue Oct 3 10:53:07 EDT 2000


 

All,

Earlier I asked a question about cloning python strings, but neglected 
to say why I needed it.
What I'm trying to do is determine how large a user process can be 
before it runs out of memory.   This is useful in debugging kernel 
parameter issues in our performance lab where our tests are running out 
of memory and I have to provide empirical proof that the kernel parms 
are set correctly and that an example program can prove it.   

Originally, I created a one-meg string, then concatenated it to itself 
until I ran out of memory (on the heap).  The number of iterations 
would give me a close approximation of the maximum date-segment size 
for a single process.   The problem is, that once the string approaches 
half or so of the kernel limit, you get a memory error....Python will 
have to malloc a string that is 1-meg larger than the original 
string....you get the idea.

So, my next thought was to simply create thousands of 1-meg strings on 
the fly using "exec".  I could then determine very accurately when the 
process ran out of memory.  (Of course, I could probably write this 
easily in C, but it would be more hastle than it's worth at this point.

Any ideas are still appreciated...and thanks to Paul and Max for their 
suggestions...
==pete==
peter.rupp at ual.com




 





More information about the Python-list mailing list